PyCone help
PyCone, the Daisy's Python: the start menu, the prompt, the editor, files, the modules in /rom and errors.
PyCone is Python for the Daisy One Plus: MicroPython 1.29 running on DaisyOS, with the Daisy's screen, sound, keyboard, card and network in the daisy module, and an editor, games, dialogs and demos kept in flash.
This page is PyCone's own help. Each topic below is also on the Daisy itself: help() at the prompt lists them, and help('editor') shows one. Everything a program can do with the screen, sound, keys and network is in the programmer's reference.
Getting started#
pycone — PyCone at a Glance#
PyCone starts at its menu (see menu); 1 gives the >>> prompt. Type a statement and press RETURN to run it; an expression's value is printed.
>>> 6 * 7
42
>>> import daisy
>>> daisy.pline(0, 0, 79, 49)
A statement that needs more lines, such as a for or a def, carries on at the ... prompt. An empty line ends it.
>>> for i in range(3):
... print(i)
...
Press AC+Z for the editor, where whole programs are written, saved and run. help() lists the help topics, and help('topic') shows one.
menu — The Start Menu#
1 Python 2 Editor 3 Terminal
4 Files 5 Settings
The Daisy starts at this menu, Daisy One Plus: five big icons on a striped blue desk, the date and time at the top, the keys at the bottom left (the arrows, RETURN to start), and at the bottom right three icons for the card, WiFi and the server, each green when ok or connected, grey when there is none or no connection, and red when it cannot be talked to (WiFi and the server once the modem has started, or failed to). The cursor keys, with CTRL or without (- = + * alone), light another icon, and RETURN starts it; or press its number (S for Settings too). 1 starts MicroPython at the >>> prompt, and 2 starts it with the editor open on a new file. 4 opens the Files screen and 5 Settings (see filescreen and settings), which shows the versions. 3 runs DaisyTerm, the terminal: AT commands go to the WiFi modem, and a call dialled with ATDT"host:port" passes straight through. AC+M opens its menu, drawn as the editor's: 1 Terminal Settings, 2 Phone Book, 3 Files/Transfers (XMODEM and YMODEM to and from the card, files chosen with the editor's file picker), 4 Disconnect TNFS (grey unless a file server is connected), 5 Reset WiFi (the modem restarted, waited for up to 20 seconds), 6 OK and 7 Exit to Menu, each by its number or the cursor keys; BREAK comes back from one of them, AC+M closes all. The Atari key with a letter goes straight there, in every mode: S settings, P phone book, F files, N the next mode, B the status bar on or off, C capture on or off, D download, U upload (in PETSCII those eight type no Commodore graphic). CTRL+Z and the other control keys go to the remote. The status bar's icons, in its middle, show the mode (VT, C= or AN), a page while capturing, a telephone, or a lightning bolt while the modem holds a connection open (daisy.carrier), and WiFi's arcs while it is joined; the clock is on the right. The phone book keeps the places you call in PHONE.TRM in the card's top folder, and dials one with RETURN; with no card, or no PHONE.TRM on it, it starts from ten BBSes DaisyTerm keeps (tools/phonebook/PHONE.TRM), and the first change saves them to the card. Terminal Settings' MODE chooses VT52, PETSCII or ANSI 80 as the menu closes. PETSCII is a Commodore 64's terminal for the colour BBSes: their colours, reverse, both cases and graphics, in the Daisy's own PETSCII font, starting in lower case as a Commodore terminal does; SHIFT+Atari swaps the case, as SHIFT+C= does. ANSI 80 is the 80-column screen with a PC's 16 colours (light grey on black to start), for the BBSes that want 80 columns. DaisyTerm starts with the colours as at power-on, the C64's, whatever a program left. BBSes learn which they are talking to: DaisyTerm gives its name (VT52, PETSCII or ANSI) and screen size to a Telnet host's asking (dial ATD and DaisyTerm answers itself, size included; ATDT and the modem answers with the name), and ANSI 80 answers an ANSI BBS's questions (the cursor's place, the screen's size). In PETSCII, CTRL+1 to 8 and the Atari key with 1 to 8 type the sixteen colours, CTRL+9 and CTRL+0 reverse on and off, and the Atari key with a letter that key's Commodore graphic (but Z, the menu); BACKSPACE is DEL, and CLEAR, SHIFT+CLEAR and INSERT are CLR, HOME and INST. Exit to Menu comes back here, and so do daisy.menu() and the editor's Exit to Menu. The menu shows whether the card is there, and after a minute untouched gives way to the pinecone, in a rainbow colour cycle, until a key is pressed.
G, which the menu does not show, plays DaisyAvenger! (see avenger), and comes back to the menu after.
U, which the menu does not show either, updates the Daisy's firmware from a file in the SD card's top folder: a firmware file built for this board, under any name. It lists the firmware files there, with the firmware and version each holds; press a file's number, then Y to flash it, or N or BREAK to go back. While it flashes, the pinecone and a bar show it; do not switch off. The Daisy then restarts into the new firmware. A file that is not firmware is not listed. "It is in pieces on the card" means the card keeps the file in separate stretches, as a card that has had files deleted may; the update reads the card block by block while the flash is rewritten, so it first copies the file into one stretch, a hidden _DAISYFW.TMP, which needs that much free room in one stretch and goes at the next update. If the update stops before the flash is touched, nothing is changed; if it stops after, the screen says to flash the Daisy over USB, which always works. DaisyVideo and DaisySound are flashed over their own USB ports.
filescreen — The Files Screen#
Two folders side by side, in 80 columns: each on any drive, ROM (/rom), SD (the card) or NET (the TNFS server Settings connects to). TAB moves between the two sides; LEFT and RIGHT change a side's drive, UP and DOWN choose, RETURN goes into a folder (.. up) or shows a file. Folders show a folder and .. an arrow up; .py and .mpy files a prompt, .txt, .md, .ini and .csv files a page, .vgm and .vgz files a double note, .chr fonts a boxed A. The letters on the bar at the top act on the file or folder chosen:
C copy M move
R rename D delete
V view E edit
H hex N new folder
F format SD
Copy and move go to the other side's folder, asking before a file or folder there is replaced. A folder goes with all in it, hidden files too; BREAK stops it between files, and a folder cannot go inside itself. Rename takes a folder too. View shows a file from any drive: UP and DOWN move a line, SPACE a page on, B a page back, F finds text (any case), N the next, H hex or text (a .chr, .bin or .mpy starts in hex), BREAK goes back. A big file shows its first 256 KB. RETURN on a .vgm or .vgz plays the song in a box with its time, a meter for each channel and the volume: LEFT and RIGHT seek, UP and DOWN set the volume, BREAK or ESC stops it. E opens the file in the editor: the screen closes and gives back its memory, and PyCone starts afresh with the editor open on it, as if started and the file loaded. E on a file that is not text, and H on any file, open it in the hex editor (see hexedit). Delete asks first; a folder goes with all in it. ROM cannot be changed. Format asks first, then erases the whole card; there is no Python command for it. BREAK goes back to the menu.
settings — Settings#
5 on the start menu, in 80 columns: each line shows what it is now, UP and DOWN choose, RETURN or its number does it, BREAK goes back. Under the lines: the card, WiFi and the server, each with its icon and what it is, as the menu's icons show them; the keys that restart the Daisy; and the versions.
- WiFi network: the networks the modem hears, each with its signal and whether it is locked; the one chosen joined, a locked one's password asked. It scans with a TNFS connection open too.
- TNFS server: its address or name and port (16384), connected;
/netis its folder then, at the prompt too. - Connect TNFS, or Disconnect TNFS while connected: Connect dials the server named in 2 (or asks for one). Whether the server still answers is asked when Settings opens and after each change (a STAT of its top folder, 2.5 s at most); one that has gone is hung up.
- Save the TNFS server as the default, in netconnect.ini on the card, which
daisy.netconnect()dials. - Date and time, typed (year-month-day, then 24-hour time).
- Time zone: hours from UTC (-5, +5:30) and whether daylight saving adds an hour, saved on the card (TIMEZONE.TXT). The start menu sets the clock from the network in it once the modem has joined WiFi, and every hour after.
- Restart the WiFi modem (as
daisy.resetwifi). - Update the firmware from the card (as U on the start menu).
keys / prompt — Keys at the Prompt#
The prompt is the Daisy's screen editor: move about the screen with the cursor keys and press RETURN on any line to run it again.
The keyboard is an Atari XEGS's. AC is its Atari key, held as a modifier. The cursor keys are CTRL with - = + * (up, down, left, right), as on an Atari. CAPS is caps lock. < is CLEAR and > INSERT (a space opened), with { } shifted and < > with CTRL. SHIFT+TAB takes back a tab, as AC+R does. A key held repeats, after a third of a second.
CTRL with a letter types a code of its own, 0x80 and the letter's place: CTRL+A is 0x81, CTRL+Z 0x9A. daisy.get gives that code; at the prompt it types the character set's glyph of it, and the terminal sends the ASCII control character. CTRL+, CTRL+. and CTRL+; give 0x80, 0x9B and 0xA0. CTRL+C and CTRL+D are the exceptions at the prompt:
- CTRL+C, or BREAK: stops a running program with KeyboardInterrupt. At the prompt, it drops the line being typed, and any statement begun at the
...prompt. - CTRL+D on an empty line: a soft reboot. PyCone starts again as at power-on, and every name defined is gone.
- AC+Z: to the editor and back again.
- AC+M: the start menu (
daisy.menu()). - AC+SPACE: insert on and off.
- CTRL+SPACE: opens a space. SHIFT+BACK S deletes the character at the cursor, and BACK S the one before it.
- TAB: to the next column of four.
- CTRL+1 to CTRL+8: the function keys, set with
daisy.key.
A line holds 159 characters on four screen rows, the prompt among them, so 155 after >>>; a key past that beeps. RETURN anywhere on the line runs all of it. Break a longer statement inside brackets and carry on at the ... prompt. In 80 columns a line holds 254.
help — Getting Help#
help() # every topic
help('pline') # one, by name
help(daisy.pline) # a function's
help(len) # Python's own
help('name') and help(thing) print the topic at the prompt. When it is longer than the screen it stops at each screenful: a key shows more, and RETURN or BREAK stops there.
help() lists every name, each beside its topic's title, under sections. The cursor keys move, a letter goes to the next name starting with it, and RETURN shows the topic; BREAK or AC+Z leaves, putting the screen back as it was. In the editor, CTRL+G opens the same list.
CTRL+W in the list finds text: it asks for it, and goes to the next name or title with it in, or the next topic whose text has it, letters matching in either case. CTRL+W and RETURN again find the next. A beep says there is none.
memory — Memory#
The banner says how much memory Python has, and gc.mem_free() how much is free now. Memory no longer used is freed when it runs short, or at gc.collect().
Modules in /rom run where they lie in flash, so their code takes no RAM: the editor, game, net, daisyui, turtle, the demos and help. The editor holds memory only while it is open, and gives it all back to run a program. When memory runs short, the editor makes room: it lets go of the names at the prompt and the modules imported there, what a program run from it left among them, and says so on its status line. Its text is never among them.
On the Daisy One Plus, Python has about 155 KB, Files lists 256 entries and views 256 KB, DaisyTerm captures 128 KB, 12 files may be open at once, and a play string holds 256 notes.
Each new name a program uses, and each short string in it, is kept until PyCone starts again. Running the same program again takes no more, but a long session of many different programs slowly takes memory. CTRL+D on an empty line at the prompt starts PyCone afresh, with all its memory free.
The editor#
editor — The Editor#
AC+Z at the prompt opens the editor, laid out as the Files screen's viewer: the title on row 0 (the file's name, with * when it has changed), the program on rows 1 to 23, a line longer than the screen running on into the rows below, and the status bar on row 24: the line and column, INS or OVR, an up arrow when the cursor's row carries on from the row above and a down arrow when its line carries on below, and the keys.
Keys type as they do at the prompt: overwrite to begin with, AC+SPACE for insert. RETURN starts a new line at the same indent, one level deeper after a line ending in a colon.
A line holds 88 characters, Black's line length: typing, joining two lines and RETURN's indent go no further, and a key that would beeps. A file's longer lines open as they are, to shorten; a file with a line longer than the screen holds (919 characters in 40 columns) is not loaded.
AC+M opens the menu, and AC+Z goes back to the prompt. Leaving the editor keeps the text on the card, and AC+Z brings it back where it was. The editor starts with the screen as at power-on, whatever a program left.
editor.keys — Keys in the Editor#
- CTRL+O: save. CTRL+R: load. Each asks for a name in a box; RETURN with none opens the file picker. In a box the cursor keys, CTRL+A and CTRL+E move, BACK S and SHIFT+BACK S delete, and CTRL+K empties it.
- CTRL+W: search.
- CTRL+Y and CTRL+N: a page up and down.
- CTRL+A and CTRL+E: the start and end of the line.
- CTRL+K: cut the cursor's line. CTRL+U: put the line last cut back above the cursor's line, as often as wanted.
- CTRL+B: mark a block from the cursor (MARK on the status bar; the block is lit as the cursor moves), CTRL+B again to stop. CTRL+K with a block marked cuts it, and CTRL+U then puts it in at the cursor.
- CTRL+Z: undo the last edit (a key's worth), and the one before it.
- CTRL+H: highlighting (Python's colours) off and on.
- CTRL+L: go to a line by its number.
- CTRL+G: help.
- AC+R: take back a tab, the spaces to the tab stop before.
- TAB: tab. AC+SPACE: insert on and off. CTRL+SPACE: open a space. SHIFT+BACK S: delete; BACK S: delete back.
- BREAK cancels any question the editor asks.
A program is coloured: Python's words, strings and comments each in a pen of their own. CTRL+H turns the highlighting off and on again.
editor.menu — The Editor's Menu#
AC+M (or BREAK) in the editor opens the menu. Choose with the cursor keys and RETURN, or the item's number; AC+M again closes it.
- Compile and run: runs the program, with none of the editor in memory, then leaves you at the >>> prompt with everything it made (its variables, functions, imports) there to look at or call. AC+Z brings the editor back, on the line an error was in.
- Search (CTRL+W).
- Save (CTRL+O).
- Load (CTRL+R): the text held goes first, so the file has all the memory to load into; a file not there, or one that is not text (a module's .mpy, a character set), leaves the text as it is; for one that is not text, a box offers to open it in the hex editor (see hexedit), the text kept meanwhile. What stops a Load or a Save shows in a box over the text; RETURN closes it. A file that is not UTF-8 is found only once read, and leaves the editor empty.
- New: empties the editor, after asking in a box (Clear the text, or Keep it).
- Help (CTRL+G).
- 80 cols (CTRL+8), or 40 cols (CTRL+4) when 80 wide: the text stays.
- Exit to REPL.
- Exit to Menu: back to the start menu, MicroPython stopped and all its memory given back (as
daisy.menu()). The text is parked as for Exit to REPL, on the card if there is one.
editor.search — Searching#
CTRL+W asks for the text to find; letters match in either case. The cursor goes to the next place it is, and the text found is shown reversed. The right and down arrows find the next one, the left and up arrows the one before; a beep says there are no more. RETURN leaves the cursor on the first letter of the text found.
Files and drives#
files / drives — Files and Drives#
PyCone has three drives:
/sd, the card. It is where PyCone starts./net, a TNFS server on another computer (tnfsd, FujiNet's and Spectranet's), oncedaisy.netconnecthas reached it./rom, read only, inside the firmware's flash: the editor, modules, demos and help, in at most 152 KB.
Python's own open reads and writes files, as text or with 'b' as bytes:
f = open('/sd/score.txt', 'w')
f.write('1234\n')
f.close()
print(open('/sd/score.txt').read())
Twelve files can be open at once. Names starting with a dot or an underscore are hidden on the card: lists leave them out, though open finds them. On /net every name is listed, as the server has it; daisyui's file picker leaves out the dot ones on either drive.
os — The os Module#
os.listdir(path) # the names
os.ilistdir(path) # (name, type..)
os.mkdir(path)
os.rmdir(path)
os.remove(path)
os.rename(old, new)
os.stat(path) # [6] is the size
os.getcwd()
os.chdir(path)
In ilistdir, a folder's type is 0x4000. A path not starting at / is taken from the current folder; os.sep is /. os.unlink is os.remove. PyCone mounts its drives itself, so os.mount and os.umount are seldom needed. Its drives do not answer os.statvfs.
shutil — Copying Files#
import shutil
shutil.copy('/sd/a.py', '/net/a.py')
shutil.move('/sd/a.txt', '/sd/b.txt')
copyfile is copy; copyfileobj(f, g) copies one open file into another. move renames, or copies and removes between drives. shutil is in /rom.
more — Page Through a File#
more('/sd/readme.txt')
Shows a file (on /sd, /net or /rom) in the viewer the Files screen uses, 80 columns wide: UP and DOWN a line, SPACE a page on and B one back, F to find text in either case and N the next, H for hex and back, BREAK to leave. The file is read into memory first, as much as fits; a longer one shows its start, "(first N KB)" in the title. When it ends, the screen, the cursor and whether printing scrolls are as they were, and nothing else of the REPL's or the editor's is touched. /net cannot be read while a socket holds the connection.
hexedit — Edit a File in Hex#
hexedit('/sd/game.bin')
Opens any file (on /sd, /net or /rom) in the hex editor, 80 columns wide: 16 bytes a row, where they are, the bytes in hex and the same bytes as text. The file is read as it is shown, not loaded, so it may be of any size. Bytes changed since the last save are red, marked ones on cyan.
- Cursor keys: a byte, a row. TAB: between the hex and the text.
- Typing: 0-9 and A-F in the hex, any key in the text. ESC: overwrite (OVR, as it starts: the length never changes) or insert (INS).
- BACK S and SHIFT+BACK S delete, CTRL+SPACE opens a 00 (INS only).
- CTRL+Y and CTRL+N: a page. CTRL+A and CTRL+E: the row's start and end, pressed again the file's.
- CTRL+B marks; CTRL+K keeps the marked bytes: INS cuts them, OVR copies them. CTRL+U puts the kept bytes in at the cursor (INS), over the bytes there (OVR), or in place of the marked ones.
- CTRL+Z: undo the last edit and the one before.
- CTRL+W: find hex (4C 00 A9) in the hex, text (either case) in the text; the cursor keys go to the next or the one before. What is found stays marked, so CTRL+U then replaces it.
- CTRL+L: go to an offset in hex, or +n and -n from the cursor.
- CTRL+I: the bytes at the cursor as numbers, on the row below. CTRL+T: the text as the Daisy's glyph for every byte, or ASCII.
- CTRL+O: save (a ROM file asks for a name on the card); AC+M the menu (Save as too); CTRL+G the keys; AC+Z leaves, asking if not saved.
A save writes the whole file anew beside the old one, then puts it in its place, so the card needs room for a second copy. When it ends, the screen is as it was, as after more(). The Pico only.
json — Saving Data#
json turns lists, dicts, numbers, strings, True, False and None into text and back, for saving a game or reading what a server sends.
import json
f = open('/sd/save.json', 'w')
json.dump({'score': 4321}, f)
f.close()
s = json.load(open('/sd/save.json'))
json.dumps and json.loads work on strings.
Modules in /rom#
game — Making Games#
import game
game.glyph(128, ['..##..',
'.####.',
'######'])
ship = game.Sprite(20, 22, 128)
while True:
dx, dy, fire = game.stick()
ship.move(dx, 0)
game.tick(20)
glyph(code, rows): draws a character from strings,#lit;bits(rows)gives the numbers fordaisy.defcharinstead.Sprite(x, y, shape): a character, a string, or a block of codes, that puts back what it covers.move(dx, dy),moveto(x, y),hide(),show(),hits(other),at(x, y),inside().stick(): (dx, dy, fire) from the joystick, the cursor keys (with AC as in the editor), W A S D and SPACE.tick(fps): waits for the next frame: the screen's own, withdaisy.frame, so each step is shown whole; by the clock without.text(x, y, s),centre(y, s),sfx(name)(blip, pick, hit, boom, win, lose),rnd(a, b),key(),wait_key()anddrain().ShapeandMob: the video board's own sprites, below.
game.Shape / game.Mob — Board Sprites#
s = game.Shape(['..##..',
'.####.',
'######'])
m = game.Mob(s, 150, 90,
colours=(7,))
m.glide(1.5, 0, across='bounce')
x, y = m.where()
The video board draws up to 16 sprites over the picture, at any pixel, without touching the characters under them, and moves and animates them by itself. Shape(pictures) draws one from strings, . see-through: any other character for one colour, 1-3 for four, 1-9 and a-f for sixteen; a list of pictures is an animation. Sizes are 16x16, 24x21 and 32x32. Mob(shape, x, y) shows it, with colours, stretch, flip, behind and hit as wanted: colours are palette entries 0-63 (one, or three for four colours), or a bank 0-3 for sixteen; stretch 1-4 across and down; behind=True shows it only where the text shows its background.
moveto,move,show,hide,set(...),free().glide(vx, vy, across, down): pixels a frame; at the edges 'carry', 'stop', 'wrap' or 'bounce'.stop()stops. Whole pixels, or 1/2, 1/4 or 1/8, move evenly; other speeds hitch.at=frameon glide, moveto and animate starts it on that frame exactly.animate(step=4, mode='loop'): a new picture every step frames, 'loop' or 'once'; withsignal(a picture) orsignals('loop', 'end', 'stop', 'bounce'),on(event, fn)calls fn when it signals, fromgame.tickorgame.events().where()andframe()work it out from the frame count;state()asks the board.game.collisions(): (Mobs each hit, Mobs touching text) since asked.game.wait(frame),game.clear()frees them all.
sprites — Using Sprites Well#
A frame takes 16.7 ms to show, and drawing sprites is most of what the board does in it: with none it draws a frame in 2.7 ms; 16 sprites of 48 by 42 take about 8 ms; 16 of 64 by 64 in sixteen colours take the whole frame, and then a frame now and then shows twice (never torn).
- The cost is each sprite's lines, every frame, moving or not: a tall sprite costs more than a wide one, and stretching down doubles it. Hide or free sprites that have left play; a hidden one, or one wholly off the picture, costs nothing.
- Fewer colours use less of the 32 KB pool: 24x21 is 64 bytes in one colour, 128 in four, 256 in sixteen.
- Let the board move and animate them (glide, animate) rather than moving each every frame: that uses no time on the Daisy and none on the link, and moves are even (a move sent each frame lands on that frame or the next). Use speeds that step evenly (glide, above).
- Make shapes once, at the start: the whole pool takes about half a second to fill.
- Collisions are by the drawn rectangle, see-through corners and all: use smaller shapes, or check closer in the program, for tight hits, and leave decorations out (
hit=False). - Use the events (
on) andwhere()/frame()rather thanstate(), which waits for the board's answer. - If the status line's miss count climbs, there are too many sprite lines: fewer, smaller or less stretched sprites.
daisyui — Dialogs#
import daisyui
daisyui.menu('Level', ['Easy',
'Hard'])
daisyui.pick_file('Load')
daisyui.pick_file('Save', True)
daisyui.ask('Name', 'Your name:')
menu gives the index of the item chosen; pick_file gives a path, and for saving, with True, lets a new name be typed. ask gives the line typed in its box, ask(title, prompt, text) starting from text: the cursor keys, CTRL+A and CTRL+E move in it, BACKSPACE and DEL take a character away, CTRL+K the whole line. A dialog puts back what it covered when it closes. AC+Z or BREAK cancels it, giving None. A program's timers go on while a dialog waits; anything they draw where it stands is lost when it closes. DaisyTerm's menus and file picker are the same dialogs.
turtle — Turtle Graphics#
from turtle import *
for i in range(5):
forward(30)
right(144)
The turtle starts in the middle facing right. forward, back, left, right, goto, home, circle, penup, pendown, pen(p) (1 on, 0 an eraser, 2 dithered), setheading, position, xcor, ycor, heading, isdown, clear and reset.
Python's short names work too: fd, bk, backward, lt, rt, setpos, setposition, seth, pu, up, pd, down and pos. speed, hideturtle, ht, showturtle, st, done and mainloop do nothing here, so programs written for Python run. Turtle() makes another turtle, with the same names as methods.
demos — Demos#
import demos
demos.menu() # choose one
demos.run('catch') # or name it
starfield, bounce, clock, life, spiral, round, catch, a game, bach, Bach's Invention 13 played with its notes on a staff, and sky, a rainbow with clouds and balloons in colour. BREAK stops one.
Their source is on the TNFS server (tnfs.pineconecomputer.com, or the Pi's), to read or open in the editor: /net/demos/PYTHON for those both Daisys run, /net/demos/PLUS for the Plus's own (sky and avenger), with xmas, a Christmas night with sprites, snow, colour cycling and Jingle Bells, too big for /rom:
daisy.netconnect()
daisy.run('/net/demos/PLUS/xmas.py')
avenger — DaisyAvenger!#
import avenger
avenger.play()
The Daisy One's game, grown for the Plus: 32 invaders march down on the city, a UFO crosses now and then, and four bunkers crumble a cell at a time. J and L (or A and D, or the cursor keys) move, I or SPACE fires, P pauses, Q goes back to the title, and Q there quits. G on the start menu plays it too, and comes back to the menu.
The ship, its laser, the bombs, the UFO and the explosions are the video board's sprites, gliding and animating by themselves; the invaders are characters, the whole block moved by one moveblock and animated by copychar. The sky lightens towards the city in four palette banks, the skyline is multicolour with windows that twinkle by colour cycling, the title song is a VGM on the sound board (/rom/lib/avenger/avenger.vgz), and the high scores are kept on the card in /sd/avenger.hi. It takes about 7 KB of memory while it plays.
Errors#
errors — Errors#
An error stops the statement and prints a traceback: the files and lines it passed through, and what went wrong.
Traceback (most recent call last):
File "/sd/game.py", line 12
NameError: name 'scroe' isn't
defined
NameError: a name not defined, often misspelt.SyntaxError: Python cannot read the line.IndentationError: a block's lines do not line up.TypeError,ValueError: a value of the wrong kind, or out of range.OSError: a file or the network;ENOENTis a file not found.MemoryError: out of memory;gc.collect()may help.KeyboardInterrupt: BREAK or CTRL+C.
Running from the editor, a key after the error brings the editor back on the line it was in.
Updated 2026-12-04