DaisyBASIC help
DaisyBASIC, the line-numbered BASIC for the Arduino Due Daisy: every statement, function and command.
DaisyBASIC needs the Arduino Due. It runs on the original Daisy One, with an Arduino Due as the main board and the DaisyOS BASIC firmware on it. The Pico Daisy on the build page runs PyCone (Python) instead, and can't run DaisyBASIC.
DaisyBASIC is a line-numbered BASIC in the old home-computer style, with commands for the Daisy's screen, colours, pixel graphics, sound board, card, and network. This is its full reference.
Getting started#
DaisyBASIC is an interactive programming language for the Daisy computer. Programs are composed of numbered lines that are stored and executed in numerical order. You can type commands directly (immediate mode) or enter numbered lines to build a program.
At power-on the Daisy shows a boot menu. Choice 1 starts DaisyBASIC.
The Boot Menu#
| Key | Starts |
|---|---|
| 1 | DaisyBASIC |
| 2 | DaisyTerm, the terminal |
| 3 | Files: the card's and the file server's folders, side by side |
| 4 | Settings: WiFi, the file server, the date and time, the versions |
The cursor keys choose and RETURN starts, or press a choice's number. Each runs until you leave it, then the menu comes back; only choice 1 leads to the BASIC prompt. AC+M at the BASIC prompt goes back to the menu, keeping the program: choosing DaisyBASIC again finds it, as on the Daisy One Plus. In Files, E on a program loads it and goes to the prompt.
DaisyAvenger!, the 3D demo and Conway's Game of Life, once on the menu, are BASIC programs on the TNFS server tnfs.pineconecomputer.com, in demos/BASIC. Connect to it in Settings, then:
LOAD "NET:demos/BASIC/AVENGER.BAS" ← J and L move, I fires, Q ends
LOAD "NET:demos/BASIC/3DDEMO.BAS" ← a cube and a pyramid, with PPOLY
LOAD "NET:demos/BASIC/LIFE.BAS" ← Life on the attribute grid
and RUN. BREAK (Shift+AC) stops each.
Updating the Firmware#
U at the boot menu, which the menu does not show, updates the Daisy's firmware from a file on the SD card. Copy the firmware file to the card's top folder, under any name: daisyos-due.bin for DaisyBASIC or pycone-due.bin for PyCone, as in the firmware folder. The update lists the firmware files it finds there, up to nine, each with the firmware and version it holds. Press a file's number, then Y to flash it; N or BREAK goes back to the menu. Files that are not firmware are left out, and so is firmware from before 2.1, which does not say what it is.
While it flashes, the screen shows the pinecone and a bar filling up. Do not switch off. The Daisy then restarts into the new firmware.
The screen may first say It is in pieces on the card: copying it into one. A card keeps a file in blocks, and a card that has had files written and deleted can hold a new file in several separate stretches: in pieces. While the flash is being rewritten, nothing that understands the card's folders can run, so the update reads the file straight off the card, block after block from where it starts, and that needs it in one unbroken stretch. A file in pieces is first copied into one, a hidden file named _DAISYFW.TMP, which takes as much free space as the firmware file, in one stretch; the next update deletes it. If the card has no such stretch, the update says No room on the card to copy it. and nothing is changed.
If something stops the update before the flash is touched, it says why, and nothing is changed: the card cannot be read, say, or a file that lies in pieces on the card cannot be copied into one piece for want of room. If the flash has been touched and the update cannot finish, the screen says Update failed: flash it over USB. Flashing the Due over USB always works, whatever its flash holds (see FLASHING.txt in the firmware folder).
Only the Due is updated this way. DaisyVideo and DaisySound are flashed over their own USB ports.
Screen Layout#
The display is 40 columns wide by 25 rows tall. Column and row numbers start at 0. The home position (top-left corner) is column 0, row 0. BORDER ON hides the outermost rows and columns, leaving columns 1–38 and rows 1–23 visible.
Line Numbers#
Line numbers must be integers from 1 to 65535. Lines are stored and executed in ascending numerical order. Entering a line number alone (with no statement) deletes that line.
10 PRINT "HELLO"
20 GOTO 10
Multiple Statements Per Line#
Separate multiple statements on one line with a colon (:).
10 FOR I=1 TO 5 : PRINT I : NEXT
Running a Program#
RUN — start from the first line
RUN 100 — start from line 100
CONT — continue after a BREAK (Shift+AC)
LIST — list all lines
LIST 10-50 — list lines 10 through 50
NEW — erase program and all variables
CLR — erase variables (keep program)
The Keyboard#
Three keys change what the others type while they are held: SHIFT, CTRL and AC. MODE does what AC does. These characters and keys are not printed on the keycaps:
| To type | Hold | and press |
|---|---|---|
\ | CTRL | 0 |
| Backquote | CTRL | AC |
\| | AC | 1 |
~ | AC | - |
^ | AC | 6 (or ,) |
_ | AC | . |
@ | AC | A |
* | AC | O |
+ | AC | P |
/ | AC | I |
{ | AC | ; |
} | AC | : |
| Pi sign | AC | K |
| Up | AC | Left arrow (or Y) |
| Down | AC | Right arrow (or H) |
| Esc | AC | E (or SPACE) |
| Tab | CTRL | I |
| Backspace | SHIFT | SPACE |
| Delete | CTRL | : |
| Insert a space | CTRL | SPACE |
| Clear screen | CTRL | L (or -) |
| BREAK | SHIFT | AC (or MODE) |
| Pause | AC | RETURN |
With SHIFT, letters are capitals, the number keys give ! " # $ % & ' ( ) and ?, and - , . ; : give = < > [ ]. Pause is Scroll Lock: it stops a running program until it is pressed again, or until BREAK.
CTRL with 1 to 8 are the function keys F1 to F8. Each types the text KEY gives it, and nothing until then.
Stopping a Program#
Press BREAK (Shift+AC) to interrupt a running program. Use CONT to resume. Press Scroll Lock to pause; press Scroll Lock or BREAK again to resume.
Variables#
Naming Rules#
Variable names start with a letter and may contain letters and digits, up to a maximum of **13 characters including any $ or % suffix**. Longer names are truncated. A trailing $ means string; a trailing % means integer. All three base-name variants exist independently of one another.
A keyword can't name a variable or an array: FLIP = 1, X = PRINT and DIM ON(3) are SYNTAX ERRORs. A longer name that starts with one (BORDERS, TOTAL) is fine, and so is a keyword with a suffix (FLIP%).
| Suffix | Type | Example |
|---|---|---|
| (none) | Numeric | SCORE |
% | Integer | COUNT% |
$ | String | NAME$ |
Numeric variables without % are stored as floating-point when needed; values that fit in a 16-bit integer are stored as integers automatically. Elements of integer arrays (DIM A%(n)) are 16-bit: −32768 to 32767.
Strings are limited to 80 characters. This applies equally to string scalars and to string array elements. Assigning a longer string silently truncates it to 80 characters — no error is raised.
Variables are instantiated when first assigned. No declaration is needed. An undefined numeric variable has value 0; an undefined string variable has value "".
LET — Assign a Variable#
LET var = expression
var = expression ← implicit LET (LET keyword optional)
10 LET X = 3.14
20 NAME$ = "DAISY"
30 SCORE% = 100
Coexistence Rule#
A scalar and an array may share the same base name; they are completely independent.
A = 5 ← scalar A
A(0) = 99 ← element 0 of array A() (requires prior DIM)
Operators#
Arithmetic#
| Operator | Meaning | Example |
|---|---|---|
+ | Addition | A + B |
- | Subtraction | A - B |
* | Multiplication | A * B |
/ | Division | A / B |
^ | Exponentiation | 2 ^ 8 |
MOD | Modulo | 10 MOD 3 |
Operator precedence (highest to lowest): ^, * / MOD, + -. Use parentheses to override.
A minus sign in front of a value negates that value alone, so 2 * -X is 2 * (-X). It comes after ^: -X ^ 2 and -2 ^ 2 are -(X ^ 2) and -4.
(MOD is a keyword which leaves % to mean the integer type suffix everywhere it appears. MOD cannot be used as a variable name.)
Comparison (used in IF and WHILE/UNTIL)#
| Operator | Meaning |
|---|---|
= | Equal |
< | Less than |
> | Greater than |
<= | Less than or equal |
>= | Greater than or equal |
<> | Not equal |
String comparisons are alphabetical (case-sensitive).
Logical (for compound conditions)#
IF A>0 AND B>0 THEN ...
IF X=1 OR Y=1 THEN ...
IF NOT FLAG THEN ...
Bitwise#
| Operator | Meaning | Example |
|---|---|---|
AND | Bitwise AND | A AND 255 |
OR | Bitwise OR | A OR 128 |
XOR | Bitwise XOR | A XOR 255 |
NOT | Bitwise NOT | NOT A |
<< | Left shift | 1 << 3 |
>> | Right shift | 128 >> 2 |
Arrays#
DIM — Declare an Array#
DIM name(n) ← 1-D array; indices 0 to n-1
DIM name(rows, cols) ← 2-D array; indices (0,0) to (rows-1,cols-1)
DIM A(10), B%(5), C$(8) ← multiple arrays in one statement
n gives the total number of elements (indices 0 through n-1). String arrays use $; integer arrays use %; float arrays have no suffix. Each dimension is from 1 to 65535; anything else gives ?ILLEGAL QUANTITY ERROR, and an array too big for memory ?OUT OF MEMORY ERROR.
10 DIM SCORE%(10)
20 FOR I=0 TO 9 : SCORE%(I)=0 : NEXT
Accessing Array Elements#
A(i) ← 1-D element i
M%(row, col) ← 2-D element
Bulk Assignment#
LET A$(0) = "RED","GREEN","BLUE"
Assigns comma-separated values starting at index 0. Gives ?BAD SUBSCRIPT ERROR if the list would exceed the array's declared size.
CLEARARR — Zero an Array#
CLEARARR name [(startIndex)] [, name [(startIndex)] ...]
Zeroes all elements from startIndex (default 0) to the end of each named array. Silently ignores arrays that have not been DIM'd. Accepts multiple arrays separated by commas.
CLEARARR SCORE% ← zero the entire SCORE% array
CLEARARR BUF$(2) ← zero from index 2 onwards
SWAPARR — Swap or Rotate Arrays#
SWAPARR a [(idx)], b [(idx)] ← swap a and b
SWAPARR a [(idx)], b [(idx)], c [(idx)] ← rotate: a←b, b←c, c←a
Swaps the contents of two arrays element-by-element, or performs a three-way rotation. An optional starting index limits the operation to that portion of each array. Arrays need not be the same size; shorter arrays are zero-filled in excess slots.
SWAPARR OLD%, NEW% ← swap two sprite buffers
SWAPARR A, B, C ← rotate: A gets B's, B gets C's, C gets A's
Input and output#
PRINT — Display Output#
PRINT ← blank line
PRINT expr ← print value, then newline
PRINT expr ; expr ← print values with no separator
PRINT expr , expr ← print values at tab stops (every 10 columns)
PRINT expr ; ← print without a trailing newline
expr may be a number, a string literal ("HELLO WORLD"), or a variable.
AT and TAB modifiers:
PRINT AT(col, row) "TEXT" ← move cursor to col,row then print
PRINT TAB(col) expr ← advance cursor to column col
10 PRINT AT(0,0) "SCORE:"; SCORE
INPUT — Read from Keyboard#
INPUT var
INPUT var1, var2 ← comma-separated values on one line
INPUT var ; ← do not print newline after entry
INPUT A$(0) ← read into array element
Waits for the user to type a value and press Enter. Multiple variables (up to four) receive fields separated by commas. No ? prompt is printed — PRINT one yourself if you want it. BREAK (Shift+AC) aborts the input and breaks the program.
GET — Read a Single Keypress (Non-Blocking)#
GET var
Reads one key from the keyboard buffer without waiting. If no key is available, numeric variables receive 0 and string variables receive "".
10 GET K : IF K=0 THEN 10 ← wait for a key
20 PRINT "KEY CODE:"; K
Key codes for special keys:
| Key | Code |
|---|---|
| Up arrow | 1 |
| Right arrow | 2 |
| Down arrow | 3 |
| Left arrow | 4 |
| Return | 13 |
| Space | 32 |
Note: BREAK (Shift+AC) is intercepted by the system for program break and is never returned by GET.
KEY — Set a Function Key#
KEY n, text$
Sets what function key n (1–8, typed with CTRL and that number) types: up to 16 characters, a RETURN (CHR$(13)) among them. Pressing the key types the text as if from the keyboard, at the prompt or to GET and INPUT in a program. KEY n, "" empties it. The keys are empty when the Daisy starts, and emptied again by a reset.
KEY 1, "LIST" + CHR$(13) ← CTRL+1 lists the program
KEY 2, "RUN" + CHR$(13) ← CTRL+2 runs it
KEY 3, "PRINT " ← CTRL+3 starts a PRINT
A key outside 1–8, or a text longer than 16 characters, gives ?ILLEGAL QUANTITY ERROR.
LOCATE — Move the Cursor#
LOCATE col, row
Moves the text cursor to the specified column (0–39) and row (0–24) without printing anything.
LOCATE 20, 12 : PRINT "CENTER"
CLS — Clear Screen#
CLS
Clears the screen and moves the cursor to the home position (0, 0).
Program flow#
REM — Remark (Comment)#
REM anything
The rest of the line is ignored, colons included, wherever the remark starts: 10 X=1: REM set: once. Use remarks to annotate your program.
10 REM *** MAIN LOOP ***
END — Stop the Program#
END
Stops program execution and returns to the Ready. prompt.
GOTO — Jump to a Line#
GOTO linenum
Unconditionally jumps to the given line number.
10 PRINT "LOOPING"
20 GOTO 10
IF / THEN / ELSE — Conditional Execution#
IF condition THEN statement
IF condition THEN linenum
IF condition THEN stmt1 : stmt2 : ...
IF condition THEN stmt1 : stmt2 ELSE stmt3 : stmt4
IF condition THEN linenum ELSE linenum
Evaluates condition. If true, executes the THEN clause; otherwise it runs the ELSE clause if there is one, or skips to the next line. Conditions may be combined with AND and OR.
10 IF SCORE > 100 THEN PRINT "HIGH SCORE!" : GOSUB 9000
20 IF A$ = "YES" OR A$ = "Y" THEN GOTO 100
30 IF K = 1 THEN GOSUB 100 ELSE IF K = 2 THEN GOSUB 200 ELSE PRINT "?"
The THEN clause runs up to the ELSE, and the ELSE clause to the end of the line; either may hold several statements, and a number on its own after ELSE is a GOTO, as it is after THEN. An ELSE belongs to the nearest IF before it that does not have one yet, so ELSE IF chains work as they read. ELSE is a reserved word; in a string or after REM it is just text.
That holds for an IF at the start of a line. An IF that follows another statement on its line guards only the one statement after THEN, and its ELSE, if any, only the one statement after ELSE; the rest of the line runs either way:
30 X=1 : IF X > 5 THEN A=1 : B=1 ← X is not over 5: A stays, B=1 runs
35 X=1 : IF X > 5 THEN A=1 ELSE A=2 : B=1 ← A=2, and B=1 runs
To make several statements depend on one condition, start a line with the IF:
30 X=1
40 IF X > 5 THEN A=1 : B=1 ← neither runs
FOR / NEXT — Counted Loop#
FOR var = start TO end
statements
NEXT [var]
FOR var = start TO end STEP step
statements
NEXT [var]
Loops with var running from start to end inclusive. STEP may be negative to count downward. Loops may be nested. NEXT alone closes the innermost loop; NEXT var closes the loop for that variable, which may be an outer one — any inner loops still open are abandoned, as in Commodore BASIC. ?NEXT WITHOUT FOR ERROR if no such loop is open.
Loops follow Commodore BASIC's rules:
NEXTgoes back to the statement just after theFOR, so theFORruns once per loop.start,endandSTEPare worked out when the loop begins; changing a variable used inendinside the loop does not change how many times it runs. Anything before theFORon its line also runs only once.- A
FORalways starts its loop afresh atstart, even if a loop on the same variable was left open byGOTO,RETURNor an error.GOTOback to aFORrestarts the loop. - The body always runs at least once; the test is made at
NEXT. A
FORmay sit in an IF's THEN clause (IF A THEN FOR I=1 TO 3 : ... : NEXT), or in its ELSE clause, and the IF is not re-checked on each pass. AFORinside an IF that is itself inside a THEN or ELSE clause (IF A THEN IF B THEN FOR ..., or... ELSE IF B THEN FOR ...) is refused with?LOOP INSIDE NESTED IF ERROR.10 FOR I = 1 TO 10 20 PRINT I 30 NEXT I
← single-line form also works, and can be nested:
10 FOR N = 0 TO 3 : PRINT N : NEXT
10 FOR I = 1 TO 3 : FOR J = 1 TO 3 : PRINT I*J; : NEXT J : PRINT : NEXT I
← loops work typed at the prompt too, without a line number:
FOR I = 1 TO 10 : PRINT I; : NEXT
A loop typed at the prompt can be stopped with BREAK.
WHILE / WEND — Pre-Test Loop#
WHILE condition
statements
WEND
Evaluates condition before each iteration. If false at the start, the body is never executed and the program carries on after the matching WEND.
WEND tests the condition again and goes back to the statement just after the WHILE, so the WHILE itself runs once per loop and anything before it on its line runs once. The loop may be on one line, may sit in an IF's THEN or ELSE clause, and works typed at the prompt. GOTO back to a WHILE whose loop is still open starts that loop again. A WHILE inside an IF that is itself inside a THEN or ELSE clause is refused with ?LOOP INSIDE NESTED IF ERROR.
10 I = 0
20 WHILE I < 5
30 PRINT I
40 I = I + 1
50 WEND
10 I = 0 : WHILE I < 5 : PRINT I : I = I + 1 : WEND
DO / UNTIL — Post-Test Loop#
DO
statements
UNTIL condition
Executes the body at least once, then repeats until condition is true. UNTIL goes back to the statement just after the DO, which runs once per loop. Like WHILE, it works on one line, in a THEN or ELSE clause and at the prompt.
10 DO
20 GET K
30 UNTIL K <> 0
EXIT — Break Out of a Loop#
EXIT
Immediately exits the innermost WHILE/WEND or DO/UNTIL loop, jumping to the statement after the closing keyword, even when that is later on the same line. Works from inside an IF THEN, and at the prompt.
10 WHILE 1
20 GET K
30 IF K = 27 THEN EXIT
40 WEND
GOSUB / RETURN — Subroutine Call#
GOSUB linenum
RETURN
RETURN expr
RETURN expr1, expr2
GOSUB saves the return address and jumps to linenum. RETURN resumes execution at the statement following the GOSUB. Subroutines may be nested.
RETURN may optionally pass up to two numeric values back to the caller. The values are retrieved with RESULT(1) and RESULT(2) after the GOSUB returns. Every RETURN resets the result state; call RESULT before the next GOSUB if you need the values.
10 GOSUB 1000
20 PRINT RESULT(1), RESULT(2)
30 END
1000 RETURN 42, 7
10 GOSUB 1000
20 END
1000 PRINT "SUBROUTINE"
1010 RETURN
ON ... GOTO / ON ... GOSUB — Computed Jump#
ON expression GOTO line1, line2, line3, ...
ON expression GOSUB line1, line2, line3, ...
Evaluates expression as an integer index (0 = first entry). Jumps to or calls the corresponding line. If the index is out of range, gives ?ILLEGAL QUANTITY ERROR.
10 ON CHOICE GOTO 100, 200, 300
DATA and READ#
Use DATA to embed constant values in a program. READ fetches the next value. RESTORE resets the pointer.
DATA — Embed Constants#
DATA value, value, ...
DATA "string", number, ...
DATA lines may appear anywhere in the program; they are skipped during normal execution. Values are read in order of line number.
READ — Fetch the Next Data Value#
READ var
READ var1, var2, ...
Reads the next item(s) from DATA into the given variables. Gives ?OUT OF DATA ERROR if no more items remain.
10 DATA 10, 20, 30
20 READ A, B, C
30 PRINT A; B; C
RESTORE — Reset the Data Pointer#
RESTORE ← reset to first DATA statement
RESTORE linenum ← reset cursor to the first DATA at or after linenum
Allows re-reading DATA from the beginning or from a specific line. linenum does not have to be a DATA line itself — the next READ scans forward from there for the next DATA statement. ?UNDEF'D STATEMENT ERROR if linenum is past the end of the program.
READMAT — Read a Whole Array from DATA#
READMAT arrayname
Reads exactly as many values as the array contains (product of its dimensions), filling elements in order (row-major for 2-D arrays).
10 DIM V(5)
20 DATA 1, 2, 3, 4, 5
30 READMAT V
40 FOR I=0 TO 4 : PRINT V(I) : NEXT
User-defined functions#
DEF FN — Define a Function#
DEF FN name(param) = expression
Defines a numeric function that can be called with FN name(value). Up to 16 functions may be defined. Functions are cleared by RUN, NEW, and CLR.
10 DEF FN SQ(X) = X * X
20 PRINT FN SQ(7) ← prints 49
The parameter name in the expression must match exactly.
A function may call another function, or itself. Each call still in progress uses memory, and a call with none left gives ?OUT OF MEMORY ERROR, which is how a function that always calls itself ends.
Numeric functions#
These return a number and may be used anywhere a number is expected.
ABS(n) — Absolute Value#
ABS(-5) → 5
INT(n) — Integer Part#
INT(3.7) → 3
INT(-3.7) → -3
Truncates toward zero (does not round down).
SQR(n) — Square Root#
SQR(16) → 4
SIN(n), COS(n), TAN(n) — Trigonometry#
By default arguments are in radians. Use DEG to switch to degrees mode.
SIN(3.14159) → ~0
COS(0) → 1
DEG : PRINT SIN(90) → 1
DEG / RAD — Trig Angle Mode#
DEG ← switch SIN/COS/TAN to degrees mode
RAD ← switch back to radians mode (default)
When DEG is active, SIN, COS, and TAN accept angles in degrees. The mode resets to radians when RUN, NEW, or CLR is executed.
DEG
PRINT SIN(90) ← prints 1
PRINT COS(180) ← prints -1
RAD
LOG(n) — Common (Base-10) Logarithm#
LOG(100) → 2
LN(n) — Natural Logarithm#
LN(2.71828) → ~1
RND(min, max) — Random Integer#
RND(1, 6) → random integer 1–6 inclusive
Both bounds are inclusive. RND(0, 1) returns 0 or 1. If min is greater than max the two are swapped automatically rather than raising an error, so RND(6, 1) behaves the same as RND(1, 6).
LEN(s$) — String Length#
LEN("HELLO") → 5
ASC(s$) — ASCII Code of First Character#
ASC("A") → 65
ASC("") → 0
VAL(s$) — String to Number#
VAL("3.14") → 3.14
Gives ?TYPE MISMATCH ERROR if the string is not a valid number.
DEC(s$) — Hex or Binary String to Integer#
DEC("$FF") → 255 ← hex (prefix $)
DEC("b1010") → 10 ← binary (prefix b or B)
The string must start with one of those prefixes; anything else, including a plain decimal number, gives ?SYNTAX ERROR. Use VAL for decimal text.
INSTR(s1$, s2$[, start]) — Find Substring#
Returns the 1-based position of s2$ within s1$, or 0 if not found. The optional start parameter (1-based) sets where to begin searching. An empty s2$ returns start (1 by default). The search is case-sensitive.
INSTR("HELLO","LL") → 3
INSTR("ABCABC","B",3) → 5
FRE(0) — Free Memory#
FRE(0) → bytes of heap remaining
The memory a program can still use for its lines, variables, arrays and strings. It is what is left of the Due's RAM once DaisyOS has its share and room is kept for the stack, or 65,536 less what the program uses, whichever is less. On the Daisy it is about 45,000 at start-up. One DIM as large as FRE(0) fits; after strings or arrays have been freed, the free memory may be in pieces too small for it.
PRESSED(col, row) — Physical Key State#
PRESSED(col, row) → 1 if key at matrix position (col, row) is pressed
Reads the live hardware state of a specific key in the 4×13 keyboard matrix (columns 0–3, rows 0–12). Returns 1 if the key is currently held down, 0 otherwise, and 0 for a position off the matrix. Program mode only.
10 IF PRESSED(0, 0) THEN PRINT "KEY AT 0,0 IS DOWN"
KEYDOWN(code) — Key Held Now#
KEYDOWN(1) → 1 if Up arrow is currently pressed
Reads the live keyboard state by scanning the keyboard matrix for a key that produces character code code. Arrow codes: UP=1, RIGHT=2, DOWN=3, LEFT=4.
Note: Every call to KEYDOWN clears the keyboard buffer. Do not mix KEYDOWN and GET in the same loop — buffered keystrokes will be lost.
JOY(n) — Joystick State#
JOY(1) → 1 if the stick is pushed up, 0 if not
JOY(0) → all five buttons at once, as a decimal bit pattern
Reads the debounced state of the joystick port. Button numbers are:
1 = up 2 = down 3 = left 4 = right 5 = trigger
JOY(0) returns the whole port as one number, with bit 0 = up through bit 4 = trigger, so several directions can be tested in a single read:
value 1 2 4 8 16
button up down left right trigger
A diagonal shows up as the sum of its parts — up+left reads as 1+4 = 5. Use AND to pick out one bit, or compare the whole value:
10 J = JOY(0)
20 IF J AND 1 THEN PRINT "UP"
30 IF J = 5 THEN PRINT "UP AND LEFT"
The port is sampled and debounced by the same 1 kHz interrupt that scans the keyboard, so a button must be held for about 3 ms before it registers (and released for about 3 ms before it clears) — contact bounce never reaches your program. Unlike KEYDOWN, JOY does not touch the keyboard buffer, so it is safe to mix with GET in the same loop.
JOY reports what the stick is doing at the moment you call it; it does not queue presses. A game loop should call it every frame, or use JOYHIT for presses.
An n outside 0–5 raises ?ILLEGAL QUANTITY ERROR.
10 REM move a character around the screen with the stick
20 X = 20 : Y = 12
30 CLS
40 PLOTCHAR X, Y, 32
50 IF JOY(1) AND Y > 0 THEN Y = Y - 1
60 IF JOY(2) AND Y < 24 THEN Y = Y + 1
70 IF JOY(3) AND X > 0 THEN X = X - 1
80 IF JOY(4) AND X < 39 THEN X = X + 1
90 PLOTCHAR X, Y, 81
100 IF JOY(5) THEN PRINT AT(0,0); "FIRE!"
110 WAITMS 33
120 GOTO 40
JOYHIT(n) — Joystick Button Pressed#
JOYHIT(5) → 1 if the trigger has been pressed since the last JOYHIT(5)
JOYHIT(0) → every button pressed since last asked, as JOY(0)'s bits
Reports presses rather than the state of the moment, so a press made between two calls is never missed, and a button held down counts once, until it is let go and pressed again. Asking about a button forgets its press; JOYHIT(0) forgets all five. Presses made before RUN are forgotten. Buttons are numbered and debounced as for JOY, and JOYHIT, JOY and GET mix freely. An n outside 0–5 raises ?ILLEGAL QUANTITY ERROR.
10 IF JOYHIT(5) THEN GOSUB 500 ← one shot per pull of the trigger
CHARAT(col, row) / GETCHAR(col, row) — Screen Character#
CHARAT(10, 5) → character code at column 10, row 5
Reads the character code at the given screen position. GETCHAR is an alias. A position off the screen, negative or past the edge, gives 0.
ATTRIBAT(col, row) — Cell Attribute#
ATTRIBAT(10, 5) → 0 if normal, 1 if reversed
Reads the text attribute of the character cell at (col, row). Corresponds to the value set by SETATTRIB. A position off the screen gives 0, so a program that counts its neighbours (as Life does) can look past the edges.
CHECKBLOCK(x, y, w, h) — Is a Rectangular Region Empty?#
CHECKBLOCK(x, y, w, h)
→ 0 if every cell in the w×h rectangle at (x, y) holds a space
(32) or a NUL (0)
→ 1 if any other character is present
Companion to FILLBLOCK for collision/free-space checks: scan a rectangular region of the text screen and report whether anything is already drawn there. Useful for placing sprites or menus into known- empty space without overdrawing existing content.
The rectangle is clipped to the visible screen — cells outside 0..39 horizontally or 0..24 vertically are ignored (treated as empty). Negative starting coordinates are clamped to 0; a zero or negative width or height yields 0 (an empty rectangle is trivially empty).
10 IF CHECKBLOCK(10, 5, 8, 3) = 0 THEN PLOTCHAR 10, 5, 65
MILLIS() — Milliseconds Since Boot#
T = MILLIS()
Returns elapsed milliseconds as a floating-point number. Useful for timing.
TIME(sel) — Read the Real-Time Clock (Time)#
TIME(0) → current hour (0–23)
TIME(1) → current minute (0–59)
TIME(2) → current second (0–59)
Reads the hardware real-time clock. The sel argument selects which field to return.
10 PRINT "IT IS "; TIME(0); ":"; TIME(1)
DATE(sel) — Read the Real-Time Clock (Date)#
DATE(0) → current month (1–12)
DATE(1) → current day (1–31)
DATE(2) → current year (e.g. 2026)
Reads the hardware real-time clock. The sel argument selects which field to return.
10 PRINT DATE(0); "/"; DATE(1); "/"; DATE(2)
POINT(x, y) — Pixel State#
POINT(40, 25) → 0 if off, 1 if solid on, 2 if dithered on
Reads the pixel-graphics layer at the given pixel coordinates (0–79 x, 0–49 y). Returns the same values accepted by PPLOT.
CURX() / CURY() — Cursor Position#
COL = CURX() ← current cursor column (0–39)
ROW = CURY() ← current cursor row (0–24)
RESULT(n) — Subroutine Return Value#
val = RESULT(1) ← first value from most recent RETURN
val = RESULT(2) ← second value
Returns the nth numeric value passed by the most recently executed RETURN statement. n must be 1 or 2. Gives ?RESULT WITHOUT RETURN ERROR if no RETURN with values has been executed, or if n exceeds the number of values returned.
SIZEARR(name, dim) — Array Dimension Size#
n = SIZEARR(A%, 1) ← number of elements in dimension 1
n = SIZEARR(M%, 2) ← number of elements in dimension 2 (2-D arrays)
Returns the declared size of the specified dimension of array name. dim must be 1 or 2. Gives ?ARRAY NOT DIM'D ERROR if the array has not been dimensioned or if dim is out of range.
NETCONNECTED() — Network Connection Status#
IF NETCONNECTED() THEN PRINT "ONLINE"
Returns 1 if a TCP session is currently active (opened with NETCONNECT), 0 otherwise. When the server hangs up, it turns 0 once everything the server sent has been read.
String functions#
String functions return strings and are used in string expressions or with PRINT.
MID$(s$, start[, len]) — Substring#
MID$("HELLO", 2, 3) → "ELL"
start is 1-based. If len is omitted, returns from start to the end.
LEFT$(s$, n) — Left n Characters#
LEFT$("HELLO", 3) → "HEL"
RIGHT$(s$, n) — Right n Characters#
RIGHT$("HELLO", 3) → "LLO"
CHR$(n) — Character from Code#
CHR$(65) → "A"
CHR$(13) → carriage return
Use to produce special or graphic characters by number.
STR$(n) — Number to String#
STR$(42) → "42"
STR$(3.14) → "3.14"
HEX$(n) — Number to Hexadecimal String#
HEX$(255) → "FF"
HEX$(4096) → "1000"
Result is 2 digits for values 0–255, 4 digits for larger values. Range: 0–65535.
BIN$(n) — Number to Binary String#
BIN$(10) → "1010"
No leading zeros (except BIN$(0) → "0"). Range: 0–65535.
TOUPPER$(s$) — Convert to Uppercase#
TOUPPER$("hello") → "HELLO"
TOLOWER$(s$) — Convert to Lowercase#
TOLOWER$("HELLO") → "hello"
CHOMP$(s$) — Trim Whitespace#
CHOMP$(" HELLO ") → "HELLO"
Removes leading and trailing spaces, tabs, and newline characters.
DATE$(sel) — Formatted Date String#
DATE$(0) → "MM/DD/YY" (US format)
DATE$(1) → "DD/MM/YY" (European format)
Returns the current date from the real-time clock as a formatted string.
10 PRINT "TODAY IS "; DATE$(0)
TIME$(sel) — Formatted Time String#
TIME$(0) → "HH:MM:SS AM" (12-hour format)
TIME$(1) → "HH:MM:SS" (24-hour format)
Returns the current time from the real-time clock as a formatted string.
10 PRINT "THE TIME IS "; TIME$(1)
ERR$(n) — Error Information (inside a TRAP handler)#
S$ = ERR$(0) ← error message text (e.g. "?FILE NOT FOUND ERROR")
S$ = ERR$(1) ← line number where the error occurred
S$ = ERR$(2) ← numeric error code as a string (use VAL() to compare)
Returns information about the most recently trapped error. Only meaningful when called from within a TRAP handler.
ERR$(0) returns the message text exactly as it would have been printed, including the trailing word ERROR where present. Compare against the full string — "?TYPE MISMATCH ERROR", not "?TYPE MISMATCH". See the ERROR MESSAGES table for the exact wording of each message. Comparing against a numeric code with VAL(ERR$(2)) avoids the issue entirely.
9000 PRINT "Caught: "; ERR$(0); " at line "; ERR$(1)
9010 RESUME NEXT
WIFI$(n) — WiFi Network Info#
S$ = WIFI$(0) ← SSID of connected network
S$ = WIFI$(1) ← IP address
S$ = WIFI$(2) ← "OK" if google.com answers a ping, "" otherwise
Queries the WiFi modem (ATI3, ATI2, AT+PING) for network information. Returns "" if not connected or if the modem does not answer. It works with a NETCONNECT session open, since the modem then still takes commands. WIFI$(0) is the name the modem keeps in its settings: "" when it joined a network its WiFi chip remembers on its own (after its settings were reset, say), until the network is joined once with WIFI from the Daisy.
String Concatenation#
Use + to join strings:
"HELLO" + " " + "WORLD" → "HELLO WORLD"
A$ + CHR$(13)
Timing and delays#
SLEEP ms — Wait#
SLEEP 1000 ← pause 1000 milliseconds (1 second)
Waits for the specified number of milliseconds. BREAK (Shift+AC) interrupts the wait. TIMER subroutines fire during SLEEP. WAITMS is an alias for SLEEP.
WAITMS ms — Wait (Alias)#
WAITMS 500
Same as SLEEP; a line written with WAITMS lists and saves as SLEEP.
TIMER — Periodic Subroutines#
TIMER interval_ms, linenum ← arm timer 0
TIMER n, interval_ms, linenum ← arm timer n (0–3)
TIMER n OFF ← disarm timer n
TIMER OFF ← disarm them all
There are four timers, 0 to 3. Each calls GOSUB linenum every interval_ms milliseconds; the subroutine ends with RETURN, which goes back to where the program was going. The call comes between program lines (never partway through an expression), after a line that jumps as after any other, and during SLEEP.
- One at a time. A timer that comes due while another timer's subroutine is running waits until that one returns; when several are due, the one longest overdue goes first. A subroutine that takes longer than its interval runs again straight after, never inside itself.
- Each keeps its pace. A timer that fires a little late is next due an interval after it was due, so its rate stays exact; one left more than an interval behind starts again from then.
- The program always gets a line. After a timer's
RETURNthe program runs at least one line before the next call, so evenTIMER 0, 0, 900cannot stop it. - A subroutine that does not
RETURNholds every timer off, and one thatSLEEPs holds the others off for that long.
Arming needs a running program (?ILLEGAL DIRECT ERROR at the prompt); OFF works anywhere. A timer number outside 0–3 gives ?ILLEGAL QUANTITY ERROR. RUN, NEW, CLR and BREAK disarm them all.
10 TIMER 0, 10, 9000 ← move the shot every 10 ms
20 TIMER 1, 35, 9100 ← and the bomb every 35 ms
30 GET K : IF K THEN GOSUB 8000
40 GOTO 30
9000 PRINT "SHOT" : RETURN
9100 PRINT "BOMB" : RETURN
TRAP — Arm an Error Handler#
TRAP linenum ← redirect any runtime error to linenum
TRAP OFF ← disarm; errors break the program as normal
When an error occurs during a running program and a trap is armed, execution jumps to linenum instead of stopping. The trap handler can inspect the error with ERR$(), then use RESUME to continue. Cleared by RUN/NEW/CLR.
Re-entry protection: while the handler is executing, the trap is suspended — any further error breaks the program normally. Trapping is re-armed automatically when RESUME is executed.
10 TRAP 9000
20 FOPEN 0, "data.txt", "R"
30 FINPUT 0, LINE$ : PRINT LINE$ : GOTO 30
40 END
9000 IF ERR$(0) = "?FILE NOT FOUND ERROR" THEN PRINT "NO DATA FILE"
9010 TRAP OFF : END
RESUME — Return from an Error Handler#
RESUME ← retry the line that caused the error
RESUME NEXT ← skip to the line after the offending line
RESUME linenum ← continue at linenum (breaks if line not found)
RESUME re-arms the trap so future errors are caught again.
RESUME linenum breaks the program with ?UNDEF'D STATEMENT ERROR if linenum does not exist — a hardcoded bad resume target is a programming error.
9000 PRINT "ERROR: "; ERR$(0); " IN LINE "; ERR$(1)
9010 RESUME NEXT
Date and time#
The Daisy has a built-in real-time clock (RTC) backed by the SAM3X crystal. Use the numeric functions TIME(sel) and DATE(sel) to read individual fields, or the string functions TIME$(sel) and DATE$(sel) for formatted output.
SETTIME — Set the Clock#
SETTIME hours, minutes, seconds
Sets the real-time clock's time. Hours use 24-hour format (0–23).
SETTIME 14, 30, 0 ← set clock to 2:30:00 PM
SETDATE — Set the Date#
SETDATE day, month, year
Sets the real-time clock's date. Year must be 2000–2099.
SETDATE 25, 3, 2026 ← March 25, 2026
Display and graphics#
REVERSE / NORMAL — Text Attributes#
REVERSE ← subsequent text is printed in reverse video
NORMAL ← return to normal video
REVERSE SCREEN ← invert the entire screen display
NORMAL SCREEN ← restore normal screen display
CHARMODE — Switch Character ROM per Row#
CHARMODE CHAR, firstrow [, lastrow]
CHARMODE GFX, firstrow [, lastrow]
Selects which character set (standard CHAR or user-defined GFX) is active for the specified screen row range. A lastrow below firstrow means firstrow alone, and one past the bottom the bottom row; CLS puts every row back to CHAR. The GFX set starts blank: every glyph is empty until DEFGFX, COPYCHAR or LOADC fills it, or GFXROM.CHR on the SD card does at boot; see LOADC / SAVEC.
DEFCHAR — Redefine a Character Bitmap#
DEFCHAR n, b0, b1, b2, b3, b4, b5, b6, b7
Redefines character n (0–255) with eight 8-bit bitmap rows. Each byte gives one row of 8 pixels; bit 7 is the leftmost pixel.
100 DEFCHAR 65, 24,60,102,126,102,102,102,0
Rows may be omitted (unchanged) or passed as computed expressions.
RESETCHAR — Restore a Character to Default#
RESETCHAR n ← restore character n
RESETCHAR ← restore all 256 characters
DEFGFX / RESETGFX — Redefine GFX Layer Characters#
Same syntax as DEFCHAR/RESETCHAR, but modifies the GFX character set used when CHARMODE GFX is active. The GFX set has no ROM, so RESETGFX blanks a character rather than restoring one.
COPYCHAR — Copy Character Bitmaps#
COPYCHAR src, dst, start ← copy char 'start' from src to dst
COPYCHAR src, dst, start, end ← copy chars start..end from src to dst
src and dst are the keywords CHAR or GFX.
- Same RAM: copy one character from index
startto indexend. Different RAMs: copy character range
start..endat the same indices.COPYCHAR CHAR, GFX, 64, 127 ← copy chars 64–127 to GFX RAM COPYCHAR GFX, GFX, 200, 210 ← copy char 200 to char 210 in GFX
LOADC / SAVEC — Load/Save Character Sets#
LOADC filename [, CHAR|GFX [, startIndex]]
SAVEC filename [, CHAR|GFX [, startIndex]]
Load or save raw bitmap data, 8 bytes per character, from startIndex up to character 255, on either drive (see FILES AND DRIVES). Default RAM is CHAR; default start index is 0. The filename goes in quotes (see FILES AND DRIVES): LOADC "SD:FONT.CHR". SAVEC refuses to replace an existing file (?FILE EXISTS ERROR) unless the name starts with -, as with SAVE.
At boot, before the menu appears, DaisyOS looks at the top of the SD card for CHARROM.CHR and GFXROM.CHR, and loads them into the CHAR and GFX sets in place of the ROM font and the blank GFX set. Each must be a whole set, 2,048 bytes, as SAVEC writes from character 0. A missing card, a missing file, a file of any other size or one that cannot be read leaves that set as it is. RESETCHAR and RESETGFX still go back to the ROM font and to blank.
SAVEC "SD:/CHARROM.CHR" ← this font at every boot from now on
SAVEC "SD:/GFXROM.CHR", GFX ← and this GFX set
LINE — Draw a Character Line#
LINE x1, y1, x2, y2, charcode
Draws a straight line from (x1,y1) to (x2,y2) using the Bresenham algorithm, filling each cell with the given character. charcode may be a number or a one-character quoted string ("*"). Coordinates are character cells (col 0–39, row 0–24). The cells off the screen are left out, so a line may start or end off it, up to 32,767 cells off either way; an end farther off gives ?ILLEGAL QUANTITY ERROR.
10 LINE 0, 0, 39, 24, 42 ← diagonal of asterisks
PLOTCHAR — Plot a Single Character#
PLOTCHAR col, row, charcode
Places charcode at the given character cell. Faster than PRINT AT because it does not move the cursor. The attribute (normal/reverse) of the cell is left unchanged — only the character is replaced.
FILLCELLS — Fill a Run of Cells#
FILLCELLS col, row, charcode, count
Fills count consecutive character cells starting at (col, row), wrapping to subsequent rows as needed.
HLINE — Horizontal Character Line#
HLINE x1, x2, y, charcode
Fills all cells from column x1 to column x2 on row y with charcode. Automatically swaps x1 and x2 if needed; clips to screen edges.
VLINE — Vertical Character Line#
VLINE x, y1, y2, charcode
Fills all cells in column x from row y1 to row y2 with charcode.
BOX — Draw a Text Box#
BOX x1, y1, x2, y2, p
Draws a rectangular border of box-drawing characters with corners at (x1, y1) and (x2, y2). p=1 draws the box; p=0 erases it (fills with spaces). Coordinates are character cells (0–39 x, 0–24 y); corners are automatically swapped and clipped if needed.
The box uses these built-in characters:
| Position | Code |
|---|---|
| Top-left | 22 |
| Top-right | 28 |
| Bottom-left | 19 |
| Bottom-right | 25 |
| Horizontal | 26 |
| Vertical | 21 |
BOX 2, 2, 37, 22, 1 ← draw a box almost full-screen
BOX 2, 2, 37, 22, 0 ← erase it
SETATTRIB — Set Cell Attribute#
SETATTRIB col, row, z
Sets the text attribute of the character cell at (col, row). z=0 sets the cell to normal video; z=1 sets it to reverse video. Does not change the character code in the cell.
SETATTRIB 10, 5, 1 ← highlight cell (10,5) in reverse video
SETATTRIB 10, 5, 0 ← restore it to normal
SCROLL — Enable/Disable Auto-Scroll#
SCROLL ON ← disable auto-scroll (screen stops scrolling when full)
SCROLL OFF ← auto-scroll on (default): new lines push old up
SCROLL 1 ← numeric: non-zero = on, 0 = off
SCROLL does not scroll the screen — it controls whether automatic scrolling occurs. With SCROLL ON the cursor stays on the last row when output reaches the bottom; no lines scroll off the top. With SCROLL OFF (the default) text scrolls up normally as each new line is added.
SCROLLX — Rotate a Band of Rows Horizontally#
SCROLLX y, height, direction
Horizontally rotates height rows starting at row y by direction columns. Positive = right; negative = left. Characters that scroll off one edge re-appear on the other edge (wrap-around, not scroll).
SCROLLXP — Slide a Band of Rows by Pixels#
SCROLLXP y, height, pixels[, cells]
Slides height rows starting at row y sideways by pixels (−7 to 7), C64 style: negative slides left, positive right. Only the picture moves; the characters stay in their cells and nothing wraps. With BORDER ON, the hidden column on the far side scrolls into view: column 39 when sliding left, column 0 when sliding right, while the border edges stay still. Each row keeps its offset until changed; SCROLLXP y,height,0 puts the rows back. The offset is only shown with BORDER ON; CLS and BORDER OFF reset every row to 0.
cells (−39 to 39, default 0) first moves the rows' characters by that many whole columns, positive to the right, without wrapping; the column that opens up gets spaces. The move and the new offset take effect in the same video frame, so stepping 1 to 7 pixels and then moving a cell and going back to 0 scrolls smoothly with no jump. Each SCROLLXP is applied in the gap between two frames, so a loop of them moves at most one step a frame (60 a second).
10 BORDER ON : CLS : N=0
20 FOR C=1 TO 39 : PLOTCHAR C,12,42 : NEXT C
30 FOR X=-1 TO -7 STEP -1 : SCROLLXP 12,1,X : NEXT X
40 SCROLLXP 12,1,0,-1
50 N=N+1 : PLOTCHAR 39,12,48+N-INT(N/10)*10
60 GOTO 30
Row 12 slides left a pixel a frame; every eighth step line 40 moves its characters a cell left and resets the offset, and line 50 draws the next digit into the hidden column 39, ready to slide in.
BORDER — Hide the Screen Edges#
BORDER ON ← black border over rows 0 and 24, columns 0 and 39
BORDER OFF ← full 40 × 25 display (default)
BORDER 1 ← numeric: non-zero = on, 0 = off
With the border on, only columns 1–38 and rows 1–23 are shown; the visible cells stay where they were. The hidden cells keep their contents and can still be written, like the C64's 38-column and 24-row modes: draw the next column of a scrolling playfield into column 39 (or the next row into row 24) while it is hidden, then SCROLLX or MOVEBLOCK it into view so it appears all at once.
A row's text/graphics mode comes from its column 0 attribute even while that column is hidden. The border takes effect from the next video frame and stays on until BORDER OFF, including after the program ends, so text printed at column 0 (such as Ready) is hidden until then.
MOVEBLOCK — Copy a Rectangular Block#
MOVEBLOCK x1, y1, x2, y2, w, h [, fillchar]
Copies the w×h rectangle of character cells whose top-left corner is at (x1, y1) to position (x2, y2). Handles overlapping regions correctly. If fillchar is given, the source region is filled with that character after the copy.
MOVEBLOCK 0,0, 10,5, 20,10 ← copy 20×10 block
SAVEBLOCK / RESTOREBLOCK — Keep a Block of Cells#
SAVEBLOCK x, y, w, h, arr% ← keep the w×h cells at (x, y)
RESTOREBLOCK x, y, w, h, arr% ← put them back, there or elsewhere
SAVEBLOCK keeps a block of character cells, text, pixels and redefined characters alike, with each cell's reverse video, in an integer array, one element a cell, row by row. RESTOREBLOCK puts them back, at the same place or another, each cell as it was, whether REVERSE is on or not. A menu or a message drawn over the screen keeps what it covers this way.
10 DIM S%(120):SAVEBLOCK 10,8,20,6,S%
20 FILLBLOCK 10,8,20,6,32:PRINT AT(12,10);"BACK IN 2 SECONDS"
30 SLEEP 2000:RESTOREBLOCK 10,8,20,6,S%
The array needs w*h elements at least. An element holds the cell's character code in its low byte and its attribute in its high byte, so a reversed cell's element is negative. A block off the screen gives ?ILLEGAL QUANTITY ERROR, an array too small ?BAD SUBSCRIPT ERROR, one that is not an integer array ?TYPE MISMATCH ERROR.
FILLBLOCK — Fill a Rectangle of Cells#
FILLBLOCK x, y, w, h, charcode ← fill entirely
FILLBLOCK x, y, w, h, startchar, endchar ← cycle chars
FILLBLOCK x, y, w, h, startchar, ← sequential fill
Three modes:
- Single char: fills
w×hcells withcharcode. - Range (startchar, endchar): cycles through
startchar..endcharrepeatedly across the cells. - Sequential (trailing comma, no endchar): fills cells with
startchar,startchar+1, … for each of thew×hcells.
Pixel graphics#
The pixel-graphics layer uses a 80×50 pixel space (four pixels per character cell, arranged in a 2×2 grid). Pixel coordinates are 0–79 (x) and 0–49 (y).
Pixel Values#
All pixel commands accept a p argument:
| Value | Meaning |
|---|---|
0 | Off (erase) |
1 | Solid on |
2 | Dithered (checkerboard on) |
Dithered pixels look 50% grey. A single character cell can contain any combination of solid-on and dithered-on pixels independently.
Block-Graphic Encoding#
Pixel cells are stored as characters using a 2×2 bit-pattern scheme:
| Range | Encoding |
|---|---|
| 0–15 | All pixels solid; bits 0–3 = TL,TR,BL,BR |
| 160–175 | All pixels dithered; same bit layout |
| 176–225 | Mixed: some pixels solid, some dithered |
Bit 0 = top-left, bit 1 = top-right, bit 2 = bottom-left, bit 3 = bottom-right. Characters 128+ are safe to use for DEFCHAR without conflicting with pixel cells.
PPLOT — Set a Single Pixel#
PPLOT x, y, p
Sets pixel at (x, y) to value p (0=off, 1=solid, 2=dithered). The other pixels in the same character cell are unaffected. A pixel off the screen, however far, is not drawn.
PLINE — Draw a Pixel Line or Rectangle#
PLINE x0, y0, x1, y1, p
PLINE x0, y0, x1, y1, p, B ← unfilled rectangle
PLINE x0, y0, x1, y1, p, BF ← filled rectangle
Without suffix: draws a Bresenham line from (x0,y0) to (x1,y1), whichever way it runs. An end below 0 is taken as 0 and one above 255 as 255. ,B: draws an unfilled rectangle with corners at the two points. ,BF: draws a filled rectangle. p may be 0, 1, or 2.
PCIRCLE — Draw an Ellipse or Arc#
PCIRCLE x, y, xr, yr, p [, startdeg [, enddeg]] [, F]
Draws an ellipse centered at pixel (x, y) with horizontal radius xr and vertical radius yr. p may be 0, 1, or 2.
Optional startdeg and enddeg (0–360) draw an arc instead of a full ellipse. 0° points right; angles increase clockwise.
Append ,F at any point after the first five arguments to flood-fill the interior of the ellipse after drawing it.
PCIRCLE 40, 25, 20, 15, 1 ← full ellipse
PCIRCLE 40, 25, 15, 15, 1, 0, 180 ← top half of circle
PCIRCLE 40, 25, 20, 15, 2 ← dithered ellipse
PCIRCLE 40, 25, 20, 15, 1, F ← filled ellipse
PCIRCLE 40, 25, 15, 15, 1, 0, 180, F ← filled half-circle
PFILL — Flood Fill#
PFILL x, y, p
Flood fill from pixel (x, y): every pixel joined to it up, down, left or right that holds the same value as it, off, solid or dithered, becomes p. p may be 0, 1, or 2; if (x, y) already holds p nothing changes. The fill reaches every pixel of the region, however large or winding.
PLINE 10,10, 30,10, 1 ← draw a closed shape first
PLINE 10,10, 10,25, 1
PLINE 10,25, 30,25, 1
PLINE 30,10, 30,25, 1
PFILL 20, 17, 1 ← fill the interior
PFILL 20, 17, 2 ← fill with dithered pattern instead
PPOLY — Draw Connected Pixel Polygons#
PPOLY draw% ← draw polygon, pixels on
PPOLY erase%, draw% ← erase first polygon, then draw second
Draws connected lines between all points in a 2-D integer array, closing the shape (last point back to first). Each array must be dimensioned as DIM arr%(n, 2) where column 0 is the pixel X coordinate (0–79) and column 1 is the pixel Y coordinate (0–49).
With two arguments, the first polygon is erased (pixels off) and the second is drawn (pixels on) in a single video message. The video board does both while the picture is on the screen, so a shape the beam passes over while it is half done can flicker; DOUBLEBUFFER and FLIP, below, keep it off the screen until it is finished.
10 DIM SH%(4, 2)
20 SH%(0,0)=20 : SH%(0,1)=10
30 SH%(1,0)=30 : SH%(1,1)=10
40 SH%(2,0)=30 : SH%(2,1)=20
50 SH%(3,0)=20 : SH%(3,1)=20
60 PPOLY SH% ← draws a square
← Animation: erase old, draw new in one atomic operation
70 DIM OLD%(4, 2) : DIM NEW%(4, 2)
80 REM ... copy current to OLD, compute new positions into NEW ...
90 PPOLY OLD%, NEW%
Maximum 125 total points across both polygons (limited by the 256-byte video message buffer).
DOUBLEBUFFER / FLIP — Draw Off the Screen, Then Show#
DOUBLEBUFFER x, y, w, h, 1 ← double buffer w × h pixels from x, y
FLIP ← show it at the next vertical blank
DOUBLEBUFFER x, y, w, h, 0 ← show it once more and stop
While a region is double buffered, pixel drawing inside it (PPLOT, PLINE, PCIRCLE, PPOLY) goes to a copy the video board keeps, and the screen shows that copy only when FLIP asks. FLIP waits for the next vertical blank, at most one screen refresh (1/60 s), and copies the region onto the screen while the beam is off it, so a frame never shows it half drawn.
The region is given in pixels and widened to whole character cells (each cell is 2 × 2 pixels). The video board has room for 880 cells with the border off (40 × 22, 30 × 25 ...) and 512 with it on (40 × 12, 30 × 17, 20 × 25), as the border uses some of the same memory; a larger region, or one off the screen, is an ILLEGAL QUANTITY ERROR.
10 DOUBLEBUFFER 0,6,80,38,1 ← 40 × 19 cells, all of shapedemo
20 PPOLY OLD%, NEW% ← erased and drawn off the screen
30 FLIP ← shown whole
40 SWAPARR OLD%, NEW% : GOTO 20
- Text and cell commands (PRINT, PLOTCHAR, FILLCELLS, BOX, ...) inside the region still draw on the screen at once, and the next FLIP covers them.
- CLS ends double buffering, discarding the copy. PFILL, and PCIRCLE with F, show the region and end it first, as the video board's fill uses the same memory.
- When the program stops (END, an error, BREAK), the region is shown and ended, so its last frame stays on the screen.
- A new DOUBLEBUFFER while one is on shows and ends the old region first.
- BORDER ON shows and ends a region of more than 512 cells; a smaller one carries on.
POINT(x, y) — Read a Pixel#
See Numeric Functions section.
Audio#
The Daisy has three sound voices. Voices 0 and 1 are pulse-wave voices with adjustable pulse width (SOUNDPWM) and pitch glide (SOUNDPRT). Voice 2 is a noise generator. There are no other waveforms and no envelopes.
BEEP — Quick Tone / Atari-style key click#
BEEP ← single C6 beep on voice 0
BEEP ON ← enable per-keystroke click (Atari 400/800-style)
BEEP OFF ← disable per-keystroke click
BEEP with no argument plays a short C6 beep on voice 0. BEEP ON enables a global key-click feature: every key pressed produces a brief 999 Hz pulse, layered across voice 0 (pulse wave) and voice 2 (noise) for an Atari-like quack. BEEP OFF disables the feature. The setting persists across RUN and NEW; only explicit BEEP OFF (or rebooting) turns it off.
SOUND — Play a Tone#
SOUND voice, freq, ms [, 1]
Starts a tone on voice (0–2) at frequency freq Hz for ms milliseconds. The optional fourth argument 1 makes the statement wait for the tone to finish before continuing. Any other voice gives ?ILLEGAL QUANTITY.
SOUND 0, 440, 500 ← 440 Hz for 0.5 seconds (returns immediately)
SOUND 0, 440, 500, 1 ← same, but waits
SHUSH — Stop a Voice#
SHUSH voice ← stop voice n and its sound program
SHUSH ← stop all voices, programs, and reset audio state
The voice is 0–2; any other gives ?ILLEGAL QUANTITY.
SOUNDPGM — Sound Programs (Music Sequences)#
SOUNDPGM n ← start playing program n (0–2)
SOUNDPGM n, array%, [R|S] ← load notes array into program n
SOUNDPGM n, R ← set program n to repeat
SOUNDPGM n, S ← set program n to play once
A sound program is a sequence of notes in a 2-D integer array with 2 columns: column 0 = frequency (Hz), column 1 = duration (ms). Terminate with a row of (0, 0).
10 DIM M%(5,2)
20 M%(0,0)=262 : M%(0,1)=200
30 M%(1,0)=330 : M%(1,1)=200
40 M%(2,0)=0 : M%(2,1)=0
50 SOUNDPGM 0, M%, R ← load and repeat on voice 0
60 SOUNDPGM 0 ← start playing
SOUNDPWM — Pulse-Width Modulation#
SOUNDPWM voice, pw, lfo_hz
Sets the pulse-width (pw, 0–255) and LFO rate (lfo_hz, 0.0 = off) for voice 0 or 1. Affects the pulse waveform type: 128 is a square wave, and a width nearer 0 or 255 sounds thinner and brighter. An lfo_hz from 0.01 to 655.35, in steps of 0.01, sweeps the width on its own, from 64 to 191 and back, in place of pw. Any other voice, width or rate is ?ILLEGAL QUANTITY ERROR.
SOUNDPWM 0, 64, 0 ← a thin pulse on voice 0
SOUNDPWM 1, 128, 4 ← voice 1 swept four times a second
SOUNDPRT — Portamento (Pitch Glide)#
SOUNDPRT voice, ms
Enables pitch glide for voice 0 or 1. ms is the glide time in milliseconds, 0 to 65535 (0 = off). The voice glides smoothly from its previous pitch to each new note. SHUSH with no voice turns glide off and puts the width back to a square wave, on both voices.
SOUNDPRT 0, 200 ← 200 ms glide on voice 0
PLAY — MML (Music Macro Language)#
PLAY string$
Plays music described by an MML string. The string is interpreted character by character (case-insensitive):
| Token | Meaning |
|---|---|
C–B | Note names (C D E F G A B) |
#/+ | Sharp (follows note) |
- | Flat (follows note) |
On | Set octave n (1–8; default 4) |
> | Octave up |
< | Octave down |
Ln | Set default note length (1=whole, 4=quarter, 8=eighth…) |
Tn | Set tempo in BPM (default 120) |
Vn | Select voice/program (0–2) |
Rn/Pn | Rest of length n |
. | Dotted note (×1.5 duration, follows note or rest) |
! | Loop: repeat the whole string until SHUSH |
Append an optional length to a note: C4 = quarter-note C.
PLAY compiles the string into a sound program (see SOUNDPGM) of up to 64 notes, loads it into the program selected by Vn (0 by default), and starts it. It returns immediately; the tune plays in the background while the program continues. SHUSH stops it.
PLAY "T180 L8 CDEFGAB>C" ← scale in eighth notes at 180 BPM
PLAY "O4 C4 E4 G4 >C2" ← C major arpeggio
PLAY "!T120 L4 CEG" ← loops until SHUSH
Network I/O#
The network serial port (Serial1, via ESP-01 WiFi module) allows communication with a TNFS file server (the NET: drive) or any other TCP server.
WIFI — Connect to a WiFi Network#
WIFI ssid$, password$
Connects to the specified WiFi network via the ESP-01 module (Zimodem firmware, ATW"ssid,password"). The modem keeps the network and joins it again after a reset, so this is needed once. A server session that is open is hung up first. Prints ?WIFI CONNECT FAILED on error.
WIFI "MyNetwork", "secret"
NETCONNECT — Open a TCP Connection#
NETCONNECT host$, port
NETCONNECT ← the host and port stored on the SD card
Dials a TCP server at host$:port in Zimodem's packet mode (ATC): the modem holds what the server sends until DaisyOS asks for it, a packet at a time, each checked and sent again if it came wrong, so nothing is lost however long a program takes between reads. Prints ?NETCONNECT FAILED on error. A session that is already open is hung up first. When the server hangs up, NETCONNECTED() turns 0 once everything it sent has been read.
With no arguments, NETCONNECT reads the host and port from SD:/netconnect.ini, a text file of name=value lines:
# my TNFS server
host=192.168.1.10
port=16384
Spaces around the names and values, either case, comments starting with # or ;, and Windows line endings are all accepted. No card, no file, or no usable host and port gives ?NETCONNECT FAILED.
Typed at the prompt with a host and port the file does not hold, NETCONNECT asks once it has connected:
Store for automatic connection? (Y/n):
RETURN or Y writes them to SD:/netconnect.ini, so a plain NETCONNECT reaches the same server next time. A running program is never asked. The connection carries raw bytes: every byte value, 255 included, passes through unchanged. (Zimodem's Telnet translation would remove byte 255 and so break binary file transfers; NETCONNECT never asks for it.) Use NETPRINT/NETGET/NETINPUT to communicate once connected.
NETCONNECT "192.168.1.10", 8000
NETDISCONNECT — Close the TCP Connection#
NETDISCONNECT
Hangs up the TCP connection (ATH and the connection's number), at once.
NETPRINT — Send Data over Network#
NETPRINT expr [; expr] [, expr] ...
Sends formatted text to the network stream. Separators ; and , both concatenate without any column spacing. No newline is appended automatically; add CHR$(13) or CHR$(10) manually if the receiver needs a line terminator.
NETPRINT "SCORE="; SCORE; CHR$(13)
NETGET — Receive Raw Bytes#
NETGET var [, var ...] [;]
Reads one byte per variable from the network stream. String variables receive the character; numeric variables receive the ASCII code.
- Default (no
;): non-blocking — assigns 0 / "" if no byte is available. Finding out takes a few milliseconds: the modem keeps what the server sends until DaisyOS asks for it. - With trailing
;: blocking — waits for each byte; BREAK interruptible.
NETINPUT — Receive a Line (Comma-Delimited)#
NETINPUT var [, var ...] [;]
Reads one newline-terminated line from the network and parses comma-separated fields into up to 4 variables (numeric or string).
- Default (no
;): non-blocking — assigns 0 / "" if no complete line (finding out takes a few milliseconds, as forNETGET). With trailing
;: blocking — waits for a complete line; BREAK interruptible.NETINPUT X, Y; ← block until "10,20\n" arrives
Files and drives#
Files live on one of two drives, and every file command works the same on both:
| Drive | Where the files are |
|---|---|
SD: | The SD card on the Due's SPI header |
NET: | A TNFS server, reached over WiFi (WIFI then NETCONNECT to the server, usually on port 16384, first). TNFS is the retro computers' network file system: FujiNet's and Spectranet's tnfsd serve it, and public servers exist. |
Any file or directory name may start with SD: or NET: to say which drive it is on. A name without a prefix is on the current drive, which is SD: when the Daisy starts, whether or not a card is present. CHDIR "NET:" or CHDIR "SD:" changes the current drive; see CHDIR. The prefix may be written in either case.
LOAD "GAME.BAS" ← from the current drive
SAVE "NET:GAME.BAS" ← to the file server, whatever is current
COPY "NET:GAME.BAS","SD:GAME.BAS"
File names must be placed in quotes. This goes for every file, directory and drive name, in every command. In a program the colon after SD or NET otherwise ends the statement: LOADC SD:FONT.CHR looks for a file called SD, not FONT.CHR. Instead of a quoted name, a command may take a string variable or any string expression, so a program can build the name it needs:
F$="SD:LEVEL"+CHR$(48+L)+".DAT"
FOPEN 0, F$, "R"
LOADC "NET:" + N$
SAVE -F$ ← overwrite, as SAVE "-..." does
Programs, character sets and data files are stored in the same format on both drives, so a file copied from one drive to the other works unchanged. SAVE writes plain text lines ending in CR LF; SAVEC writes eight raw bytes per character.
Each drive keeps its own current directory. With no card fitted, every SD: operation fails with ?DEVICE NOT PRESENT ERROR; the boot menu shows the card's state (SD OK, SD FAIL or No card) on its status bar.
File errors are ordinary BASIC errors on both drives: they stop a running program, and a TRAP handler can catch them. See File Errors.
LOAD — Load a Program#
LOAD filename
Reads a BASIC program from a file. The filename is required (?MISSING FILE NAME ERROR otherwise) and goes in quotes. FOUND is printed once the file is known to exist; a missing file is ?FILE NOT FOUND ERROR.
LOAD does not clear the program already in memory: each incoming line is entered exactly as if you had typed it, so it replaces a line with the same number and leaves every other line alone. Type NEW first unless you mean to merge. May be used inside a running program.
NEW
LOAD "mygame.bas"
SAVE — Save a Program#
SAVE filename
SAVE -filename ← overwrite an existing file
Writes the current program to a file as plain BASIC text and prints Saved. If the file already exists, SAVE stops with ?FILE EXISTS ERROR unless the name starts with -. The dash goes before any drive prefix: SAVE "-SD:mygame.bas", or before a name in a variable: SAVE -F$. May be used inside a running program.
SAVE "mygame.bas"
CAT / CATALOG — Display File Catalog#
CAT
CAT "SD:"
CAT "NET:"
CAT "SD:/stories"
Lists the current directory: the drive and path first, then directories (marked <DIR>) and files with their sizes in bytes. With a drive prefix it lists that drive's current directory instead of the current drive's. A directory can be named, on either drive, and is listed without changing into it. CATALOG is an alias for CAT. On the SD card, hidden files and names starting with . or _ are left out; on NET: every name is listed, as the server has it.
Sizes start in column 17, or two spaces after a name too long for that. A listing longer than the screen stops before each further screenful with Strike any key to continue... in reverse video on the bottom line: any key goes on, and BREAK ends the listing. CAT is typed at the prompt; in a program it is a ?SYNTAX ERROR.
DEL / DELETE — Delete a File#
DEL filename
DELETE filename
Deletes filename, which goes in quotes. Prints ?FILE NOT FOUND ERROR if the file does not exist. Directories cannot be deleted.
DEL "oldprog.bas"
REN / RENAME — Rename a File#
REN oldname, newname
RENAME oldname, newname
Renames oldname to newname. Both names go in quotes. The new name stays on the old name's drive (REN "NET:A","B" renames within NET:); naming a different drive for it is a ?RENAME ERROR, so use COPY and DEL to move a file between drives. ?FILE EXISTS ERROR if newname is already taken.
REN "prog.bas", "backup.bas"
COPY — Copy a File#
COPY source, destination
Copies source to a new file named destination. The two may be on different drives, which is how files move between the SD card and the file server; an unprefixed destination is on the current drive. Prints ?FILE NOT FOUND ERROR if the source does not exist and ?FILE EXISTS ERROR if the destination does. A copy that fails partway is deleted rather than left incomplete.
COPY "prog.bas", "prog_bak.bas"
COPY "NET:prog.bas", "SD:prog.bas"
CHDIR — Change Directory#
CHDIR dirname
CHDIR "SD:"
CHDIR "NET:/games"
Changes the current directory. Subsequent file operations (LOAD, SAVE, CAT, DEL, REN, COPY, FOPEN, etc.) work relative to it. Prints ?DIR NOT FOUND ERROR if the directory does not exist or would escape the server's root.
A name with a drive prefix also makes that drive current: CHDIR "SD:" changes only the drive, keeping its directory, and CHDIR "NET:/games" changes both. Changing to SD: with no card fitted gives ?DEVICE NOT PRESENT ERROR and leaves the current drive alone; if a card has been inserted since the Daisy started, it is mounted then.
CHDIR "games" ← enter the games/ subdirectory
CHDIR ".." ← go up one level
CHDIR "/" ← return to the root directory
Note: The NET: directory belongs to the server connection and resets to / when a new connection is established. The SD: directory resets to / when a card is mounted.
MKDIR — Create a Directory#
MKDIR dirname
Creates a new directory relative to the current directory. Intermediate directories are created automatically. Prints ?DIR EXISTS ERROR if the directory already exists.
MKDIR "games"
MKDIR "games/saves" ← creates both games/ and games/saves/ if needed
FORMAT — Erase a Drive#
FORMAT "SD:"
Erases everything on a drive and leaves an empty file system. Only a drive on physical media can be formatted, which today means the SD card: the device is written "SD:" or "SD", in quotes, in either case. FORMAT "NET:", a device that does not exist, or a path such as "SD:/GAMES" is refused with ?ILLEGAL DEVICE ERROR, and with no card fitted the answer is ?DEVICE NOT PRESENT ERROR. Both are reported before anything is asked or changed.
Otherwise FORMAT asks first:
Warning: formatting is destructive to
data. Proceed? (Y/N)
Only Y goes ahead. Any other key, including RETURN and BREAK, prints Format cancelled. and leaves the card exactly as it was. Keys typed before the question appears are thrown away, so they cannot answer it.
FORMAT "SD:"
Warning: formatting is destructive to
data. Proceed? (Y/N) Y
Formatting...
Formatted SD:
Files open on the card are closed first (later FPRINTs to those channels give ?FPRINT ERROR); files open on NET: are not touched. The card's current directory goes back to the root. The new file system is FAT16 on a card of 2 GB or less, FAT32 up to 32 GB and exFAT above, laid out the way the SD Association's own formatter does it, and only takes a few seconds. The card is then checked with the same write and read-back test as at boot; if formatting or that check fails, the result is ?FORMAT ERROR.
FORMAT is also the way to rescue a card the boot menu reports as FAIL: such a card answers but holds no usable file system. The program in memory and the help file in flash are not affected. FORMAT can be used inside a running program; it still asks.
Sequential file I/O#
DaisyBASIC can read and write files on either drive (see FILES AND DRIVES). Files are accessed via numbered channels (0–3), and each channel may be open on either drive. A failed operation raises an error.
FOPEN — Open a File#
FOPEN channel, filename, mode
Opens filename and assigns it to channel (0–3). The name may carry a SD: or NET: prefix. Opening a missing file for reading is ?FILE NOT FOUND ERROR. mode is a string: "R" or "READ", "W" or "WRITE" (truncates), "A" or "APPEND". Any other mode string is treated as read.
FOPEN 0, "data.txt", "W"
FCLOSE — Close a File#
FCLOSE channel
Flushes and closes the file on the given channel.
Note: any channels still open are auto-closed by RUN, NEW, CLR, and BREAK so a program that errors out mid-stream doesn't leak open files. A program that ends cleanly with END (or by running off the end) leaves its channels open so you can continue to FINPUT/FGET from the prompt; the next RUN then closes them.
FPRINT — Write a Line to a File#
FPRINT channel, expr [; expr ...] [, expr ...]
Formats the items and writes them to the file as one line: a newline (CHR$(10)) is added after them, so each FPRINT is one line that a later FINPUT reads back. Separators ; and , both concatenate with no spacing. To write without a newline, use FPUT.
FPRINT 0, "NAME="; NAME$
FINPUT — Read a Line from a File#
FINPUT channel, var [, var ...]
Reads one complete newline-terminated line per variable. Commas inside the file are treated as literal data, not field separators. Assigns 0 / "" on EOF. An empty line also reads as "", so use FBYTES to tell a blank line from the end of the file.
FINPUT 0, LINE$
FGET — Read a Single Byte#
FGET channel, var
Reads one byte from the file. String variables receive the character; numeric variables receive its ASCII code. Assigns 0 / "" on EOF.
FPUT — Write a Single Byte#
FPUT channel, expr
Writes one byte (the integer value of expr) to the file.
FSEEK — Move the File Cursor#
FSEEK channel, delta
Shifts the file cursor by delta bytes relative to its current position. Use a positive value to move forward, negative to move backward.
FSEEK 0, -1 ← back up one byte
FSEEK 0, 10 ← skip forward 10 bytes
FREWIND — Seek to Start of File#
FREWIND channel
Repositions the file cursor of channel (0–3) back to byte 0. Raises ?FSEEK ERROR if the seek fails or the channel is not open.
10 FOPEN 0, "log.txt", "R"
20 FINPUT 0, A$ ← read first line
30 FREWIND 0 ← rewind to start
40 FINPUT 0, A$ ← read first line again
50 FCLOSE 0
FBYTES — Bytes Remaining#
n = FBYTES(channel)
Returns the number of bytes remaining from the current cursor position to the end of the file.
Example — write then read back a file:
10 FOPEN 0, "test.txt", "W"
20 FPRINT 0, "HELLO"
30 FCLOSE 0
40 FOPEN 0, "test.txt", "R"
50 FINPUT 0, A$
60 FCLOSE 0
70 PRINT A$
System commands#
LIST, RUN, CONT, NEW, CLR, RENUMBER, REBOOT, TERM, HELP and CAT work only in immediate mode. VERSION, CHUNK and MORE also work inside a program. The programs that were on the boot menu (see The Boot Menu) are not commands.
LIST — Display the Program#
LIST ← list entire program
LIST 10 ← list line 10 only
LIST 10-50 ← list lines 10 through 50
LIST 10- ← list from line 10 to the end
Press BREAK (Shift+AC) to abort a long listing. Press Scroll Lock to pause.
RUN — Execute the Program#
RUN ← run from the first line
RUN 100 ← run from line 100
Clears all variables before starting. GOTO 100 typed at the prompt does the same as RUN 100.
CONT — Continue After Break#
CONT
Resumes execution from where it stopped after a BREAK, or retries the line that raised an untrapped error. BREAK is noticed between lines; if the program was about to continue partway along a line (going round a one-line loop, or coming back from a GOSUB), CONT carries on from that exact statement. A BREAK that cuts short a statement waiting for input (INPUT, or a blocking NETGET or NETINPUT) runs that statement again; inside an IF's THEN or ELSE clause the whole line is run again instead. A program that finished with END or ran off its last line cannot be continued: CONT then gives ?UNDEF'D STATEMENT ERROR.
NEW — Erase Program and Variables#
NEW
Deletes the entire program and all variables and arrays.
CLR — Clear Variables#
CLR
Frees all variables, arrays, FOR/GOSUB/WHILE stacks, and user functions. The program text is kept.
VERSION — Display the DaisyOS Version#
VERSION
Prints the DaisyOS version, and the date it was built under it:
DaisyOS 2.1.0
Oct 21 2026
The video board's own version is shown at the bottom right of the screen while the pinecone is up at power-on.
CHUNK — Split a String into an Array#
CHUNK arr$, string$ [, delimiter$]
Splits string$ at each occurrence of delimiter$ (default: a single space) and places the pieces into successive elements of arr$, which must be a pre-dimensioned string array.
DIM W$(5)
CHUNK W$, "ONE TWO THREE" ← W$(0)="ONE", W$(1)="TWO", W$(2)="THREE"
CHUNK W$, "A,B,C", "," ← split on comma
Useful with CHOMP$ when fields may have surrounding whitespace.
RENUMBER — Renumber Program Lines#
RENUMBER start [, step]
Renumbers all program lines starting from start with an increment of step (default 5). All GOTO, GOSUB, THEN, ELSE, ON, RESTORE, TRAP, RESUME and TIMER line references are updated automatically. Every other number stays exactly as typed. Immediate mode only.
Prints ?RENUMBERING OVERFLOW if any new line number would exceed 65535. start must be in the range 1–65535 or you get ?ILLEGAL LINE NUMBER, and step must be at least 1 or you get ?ILLEGAL QUANTITY ERROR.
RENUMBER 100 ← renumber from 100, step 5
RENUMBER 10, 10 ← renumber from 10, step 10
MORE — Page Through a File#
MORE filename
Opens filename, on either drive, and displays it one screenful at a time. The filename goes in quotes. Unlike the other system commands, MORE also works inside a running program.
While paging:
| Key | Action |
|---|---|
| Space | Next page |
| Backspace | Previous page |
: or Ctrl-W | Search — opens a / prompt on the status bar |
| BREAK / Ctrl-C | Quit |
At the / prompt, type text and press Enter to search forward from the current page; the search wraps to the start of the file if nothing is found ahead. Pressing Enter on an empty prompt repeats the previous search. A status bar shows the current page, the page count, and search results. Until the last page has been seen, the count is an estimate from the file's size, shown with a ~ (Pg 2/~5).
MORE "readme.txt"
A file whose name ends in .HLP is a help file, and MORE opens it in help mode: a list of its topics, two columns of names, with the selected one in reverse video.
| Key | Action |
|---|---|
| Arrows | Move through the list (left and right move a column) |
| Space / Backspace | Next or previous screen of the list |
| A letter | Next topic starting with that letter |
: | Search every topic's text; selects the topic the text is in |
| Return | Show the selected topic |
| BREAK / Ctrl-C | Quit |
A topic is paged like any file, with Space, Backspace and : (Enter at the / prompt repeats the list's search inside the topic). Return goes back to the list; BREAK quits.
A topic ends with a See also: list of related topics, which are links. The arrows pick one, naming it on the status bar, and Return shows it instead of going back to the list. Paging or a search drops the link picked. In HELP.HLP, a subject lists its keywords and the subjects and keywords related to it, and a keyword lists the subjects it is described in.
A help file is plain text. Each topic starts with a line of @ and the topic's name (up to 19 characters), and its text runs to the next @ line; lines before the first topic are not shown. A topic's links are the names, separated by commas, from a line starting See also: to the end of the topic. The list is in the order of the file. A name in capitals is a keyword's; any other name is a subject's. A .HLP file with no topics is paged as plain text. HELP.HLP, the help for DaisyBASIC, is made from this manual by tools/mkhelp.py: the manual's sections come first, from Introduction to Quick Reference, then every keyword from A to Z.
HELP — Look Up a Keyword#
HELP
HELP keyword
Opens HELP.HLP at the top of the SD card in MORE's help mode. With a keyword, its topic is shown straight away; Return then goes to the list with that topic selected. Only the first word counts (HELP DEF FN finds DEF). If no topic has the whole name, a keyword whose name starts with the word is found, and failing that any topic that does: HELP STR finds STR$, not String Functions. A word with no topic leaves the list at the top, saying No topic: word. HELP is typed at the prompt; it does not run in a program.
The firmware brings HELP.HLP with it. A fresh image holds the file in flash bank 1, and at power-on the Daisy writes it to a card that has no HELP.HLP. A HELP.HLP already on the card is never replaced: to have a newer one written, delete it before the first boot of new firmware. The file can also be made from the DaisyOS sources with python3 tools/mkhelp.py and copied to the card.
HELP PRINT
HELP MID$
REBOOT — Restart the Computer#
REBOOT
Performs a hardware reset. All program and variable data is lost.
TERM — VT52 Terminal Emulator#
TERM
Launches the built-in VT52 terminal emulator. The terminal talks to the WiFi modem itself: AT commands typed go to it, and a call dialled with ATDT passes straight through. A NETCONNECT session is hung up first. It supports:
- VT52 escape sequences (cursor movement, clear screen, graphics mode)
- ANSI arrow key sequences
- Configurable local echo, return key mode, bell mode, screen polarity, modem link speed (38400 or 115200), and flow control
- Status bar with date/time display
- A text buffer that captures what the remote sends
- XMODEM and YMODEM file transfers to and from the SD card
Press AC-M to open the configuration menu; every control key, CTRL-Z included, goes to the remote. Move with the up and down arrows (or , and .), change a setting with left and right, and press RETURN to choose. PHONE BOOK and FILES AND TRANSFERS open the menus described below. Select EXIT TO BASIC to return to the BASIC prompt.
DaisyTerm takes about 5 KB for its screen, transfer buffers and phone book while it runs and gives it back when it ends. If a program leaves less than that free, TERM says Not enough memory for DaisyTerm and does nothing.
BAUD sets the speed of the link to the WiFi modem: [115200], the default, or [38400]. The change takes effect at once and also applies to BASIC's NET: drive and network commands, until the next reset brings back 115200.
BAUD does not change the modem's own speed; Zimodem keeps its own, and DaisyOS expects 115200. A modem that has lost its settings answers at 1200: set it once by typing ATB115200 with BAUD to match, then AT to check that it answers OK, and AT&W to save the speed so it keeps it after a power cycle. To use 38400 instead, type ATB38400 and change BAUD to match; a reset brings back 115200 on the Daisy's side.
FLOW is the modem's flow control for a call dialled here: [CTS], the default, or [NONE]. With CTS, DaisyTerm tells the modem to stop sending while it is busy drawing, so nothing a busy screen brings is lost; the modem then sends at about 1-2 KB a second, about a 14.4k modem's speed. With NONE it sends as fast as the link goes, and what comes while DaisyTerm is busy can be lost. Set FLOW before dialling: changing it sends the modem a command, which during a call would go to the far end.
To reach a telnet BBS, dial it with ATDT"host:port": the T makes the modem handle the telnet protocol, which binary transfers need. A plain raw-TCP service is dialled with ATD"host:port".
The text buffer#
The buffer is a block of memory, up to 32 KB, that keeps a copy of what arrives from the remote, exactly as sent. It is taken only when first used and given back when the terminal exits.
| Item | What it does |
|---|---|
| CAPTURE | [ON] copies everything that arrives into the buffer; [OFF] stops. When the buffer fills, capture stops and shows [FULL]. |
| VIEW BUFFER | Pages through the buffer as plain text, with escape codes removed: SPACE for the next page, B for the previous one, BREAK to finish. |
| SAVE BUFFER | Writes the buffer to a file on SD:, escape codes and all. Asks before replacing a file. |
| LOAD BUFFER | Reads a file from SD: into the buffer (only the first 32 KB of a bigger file). |
| SEND BUFFER | Types the buffer out to the remote, a line at a time, as if from the keyboard. Each line ends as the RETURN setting says. Press BREAK to end it early. |
| CLEAR BUFFER | Empties the buffer. |
While capturing, the status bar shows how full the buffer is (CAP 12%), and while sending, how far the send has got (SEND 40%). Capture stops while the buffer is being sent, so the remote's echo is not added to what is being sent. If the buffer holds text that has not been saved, leaving the terminal or replacing the buffer asks first.
File transfers#
PROTOCOL picks XMODEM, XMODEM-1K or YMODEM; change it with left and right. DOWNLOAD receives from the remote and UPLOAD sends to it. Start the transfer on the remote first, or within a minute after. A box shows the file, the bytes so far and a progress bar. BREAK abandons the transfer, and a file that did not arrive whole is deleted.
| Protocol | Notes |
|---|---|
| YMODEM | The best choice when the remote offers it. The sender supplies each file's name and exact size, and several files can come in one go. Downloads go into the SD card's current directory; a name already there gets _1, _2 and so on added. |
| XMODEM-1K | 1 KB blocks. No name or size: you name the file, and it is padded to a whole number of 128-byte blocks with Ctrl-Z characters. |
| XMODEM | 128-byte blocks, for remotes with nothing newer; falls back to checksums for very old senders. Same padding as XMODEM-1K. |
Files are read from and written to SD: only. Names typed in the files menu are on the card even if NET: is the current drive, and NET: names are refused, because the file server would need the very connection the terminal is using.
The phone book#
PHONE BOOK in the menu lists the places you call, up to 20, each with a name, a host, a port, and how to dial it: ATDT for a telnet BBS, or ATD for a raw TCP service. Move with the up and down arrows; the host and port of the one selected show under the list.
| Key | What it does |
|---|---|
| RETURN | Dials the entry: the menu closes and DaisyTerm types ATDT"host:port" (or ATD"host:port") and RETURN to the modem. Hang up any call first (+++, then ATH). |
| A | Adds an entry: it asks for the name, the host, the port (23, telnet's, is offered) and T for ATDT or D for ATD. BREAK cancels. |
| E | Edits the entry, asking the same questions, each starting from what it holds. |
| D | Deletes the entry, once you press Y. |
| BREAK | Goes back to the menu. |
The phone book is kept in PHONE.TRM in the SD card's top folder, read when DaisyTerm starts and written again after each change, one entry a line:
ATDT,bbs.example.com,23,Example BBS
ATD,192.168.1.9,7000,My server
The name comes last and may hold commas. A host may not hold spaces, commas, quotes or colons, and a port runs from 1 to 65535. Lines that are not entries, comments among them, are left out of the list, and dropped the next time the phone book is written. With no card, the list can be used but not saved.
Special notes and tips#
Line Editing#
- Backspace deletes the last character typed.
- Enter submits the line.
- Ctrl-C cancels the current input line.
- BREAK (Shift+AC) interrupts a running program; use
CONTto resume. - Scroll Lock pauses a running program (press again to resume).
Immediate Mode Evaluation#
Any valid statement typed without a line number executes immediately:
PRINT 2 + 2 ← prints 4
X = 100 : PRINT X ← assigns then prints
Multi-Line Programs#
Type each line with a line number to build your program. When done, type RUN.
10 FOR I=1 TO 5
20 PRINT I*I
30 NEXT
RUN
Keep Lines to 79 Characters#
Keep each program line, line number included, to 79 characters as you write it and as LIST shows it. The screen editor reads a line as at most two 40-column rows, so pressing Enter on a longer listed line, or typing one, keeps only its first 80 characters, and the statements cut off are lost. Split a long line across new line numbers instead. A program loaded from a file may have longer lines, up to 255 characters; LIST, SAVE, RENUMBER and RUN handle them whole, and stop with ?LINE TOO LONG ERROR on one too long to handle rather than drop part of it.
Deleting a Line#
Type just the line number and press Enter:
20 ← deletes line 20
Colon-Separated Statements#
Multiple statements fit on one line, separated by colons. REM must be the last statement on the line (it consumes everything after it).
Variables Are Case-Insensitive#
SCORE, Score, and score all refer to the same variable.
GOTO Out of FOR Loops#
Jumping out of a FOR loop with GOTO is safe (Commodore BASIC behaviour). The stack entry is replaced when the loop variable re-enters a FOR.
RESTORE with a Line Number#
RESTORE 1000
Moves the READ pointer to the first DATA statement at or after line 1000, useful for targeting specific data blocks.
Special characters#
Block-Graphic Pixel Characters#
The pixel-graphics commands use character codes 0–225 to represent 2×2 pixel cells. **Do not use these ranges for text or DEFCHAR unless you know what you are doing**, as they are maintained by the pixel commands.
| Range | Contents |
|---|---|
| 0–15 | Solid pixels; bit n = pixel state (TL/TR/BL/BR) |
| 160–175 | Dithered pixels; same bit layout |
| 176–225 | Mixed cells: some pixels solid, some dithered |
Box-Drawing Characters#
Used by the BOX command:
| Code | Glyph |
|---|---|
| 19 | Bottom-left |
| 21 | Vertical bar |
| 22 | Top-left |
| 25 | Bottom-right |
| 26 | Horizontal |
| 28 | Top-right |
User-Definable Range#
Characters 128–159 and 226–255 are safe for DEFCHAR/DEFGFX without conflicting with pixel cells or box-drawing characters.
Other Notable Characters#
| Code | Description |
|---|---|
| 32 | Space |
| 42 | Asterisk * |
| 65–90 | A–Z |
| 97–122 | a–z |
| 235–254 | Pinecone logo, 4 wide × 5 tall, row by row (the boot menu draws it with FILLBLOCK 1,1,4,5,235,254) |
| 255 | Checkerboard |
Error messages#
Messages are listed exactly as they are printed. Note that most end in the word ERROR — this matters when comparing against ERR$(0) inside a TRAP handler, which returns the full text.
Interpreter Errors#
| Error | Meaning |
|---|---|
?SYNTAX ERROR | Unrecognised statement or bad syntax |
?TYPE MISMATCH ERROR | String/numeric type error |
?ILLEGAL QUANTITY ERROR | Numeric value out of the legal range |
?ILLEGAL DIRECT ERROR | Program-only command used in immediate mode |
?ILLEGAL LINE NUMBER | Line number not in range 1–65535 |
?UNDEF'D STATEMENT ERROR | GOTO/GOSUB to a non-existent line number |
?LINE TOO LONG ERROR | Line too long to enter, list, save or run |
?FORMULA TOO COMPLEX ERROR | Expression of more than 32 parts, or too long |
?LOOP INSIDE NESTED IF ERROR | FOR, WHILE or DO inside an IF that is inside a THEN or ELSE clause |
?ARRAY NOT DIM'D ERROR | Array used before DIM |
?BAD SUBSCRIPT ERROR | Array index out of range |
?WRONG NUMBER OF DIMENSIONS ERROR | 1-D access on 2-D array or vice-versa |
?DIVISION BY ZERO ERROR | Division or modulo by zero |
?OUT OF DATA ERROR | READ with no more DATA values |
?NEXT WITHOUT FOR ERROR | NEXT with no matching FOR |
?RETURN WITHOUT GOSUB ERROR | RETURN with no GOSUB on the stack |
?WEND WITHOUT WHILE ERROR | WEND with no matching WHILE |
?WHILE WITHOUT WEND ERROR | WHILE with no matching WEND found |
?UNTIL WITHOUT DO ERROR | UNTIL with no matching DO |
?DO WITHOUT UNTIL ERROR | DO with no matching UNTIL found |
?EXIT NOT IN LOOP ERROR | EXIT used outside a WHILE or DO loop |
?OUT OF MEMORY ERROR | Heap exhausted, or functions nested too deep |
?RESULT WITHOUT RETURN ERROR | RESULT(n) called with no RETURN values available |
?RESUME WITHOUT TRAP ERROR | RESUME/RESUME NEXT with no trapped error state |
?RENUMBERING OVERFLOW | RENUMBER would push a line number past 65535 |
?UNKNOWN ERROR | Internal fallback for an unrecognised error code |
BREAK IN LINE n | BREAK pressed; use CONT to resume |
Network Errors#
| Error | Meaning |
|---|---|
?WIFI CONNECT FAILED | Could not connect to the specified WiFi network |
?NETCONNECT FAILED | TCP connection to host/port could not be opened |
File Errors#
File errors read the same on both drives and can be caught with TRAP.
| Error | Meaning |
|---|---|
?FILE NOT FOUND ERROR | The named file does not exist |
?FILE EXISTS ERROR | SAVE/SAVEC/REN/COPY: the target exists already |
?DIR NOT FOUND ERROR | CHDIR target missing, or escapes the server root |
?DIR EXISTS ERROR | MKDIR target already exists |
?DEVICE NOT PRESENT ERROR | SD: used with no card fitted |
?ILLEGAL DEVICE ERROR | FORMAT: not a drive that can be formatted (only SD:) |
?FORMAT ERROR | FORMAT: the card could not be formatted, or failed its check afterwards |
?MISSING FILE NAME ERROR | The command needs a filename |
?FOPEN ERROR | The file could not be opened |
?FCLOSE ERROR | The file could not be closed |
?FPRINT ERROR | The write failed, or the channel is not open for writing |
?FPUT ERROR | The byte write failed |
?FSEEK ERROR | FSEEK or FREWIND failed |
?LOAD ERROR | LOAD or LOADC failed partway, or the server stopped answering |
?SAVE ERROR | SAVE or SAVEC could not write the file |
?CATALOG ERROR | The directory could not be listed |
?MKDIR ERROR | Directory could not be created |
?DELETE ERROR | File could not be deleted |
?RENAME ERROR | File could not be renamed, or REN named another drive |
?COPY ERROR | File could not be copied |
?EMPTY FILE | MORE: the file opened but contains no data |
?OUT OF MEMORY | MORE: could not allocate its page-offset table. Note this one has no ERROR suffix, unlike the interpreter's ?OUT OF MEMORY ERROR |
The NET: drive turns the file server's replies into these same messages. When the server does not answer in time, the command's own error is used (for example ?LOAD ERROR).
Quick reference#
Immediate-Mode Commands#
LIST [start[-end]] NEW REBOOT
RUN [linenum] CLR TERM
CONT
LOAD file SAVE [-]file CAT / CATALOG
DEL file REN old,new COPY src,dst
CHDIR dir MKDIR dir
CHDIR "SD:" / "NET:" (any name may start SD: or NET:)
(file names in quotes, or a string expression)
LOADC file[,...] SAVEC file[,...]
VERSION CHUNK arr$, str$[, delim$]
RENUMBER start[,step]
HELP [keyword]
Program Statements#
REM ... LET var = expr
PRINT [expr[;|,]...] INPUT var[,var...][;]
GET var LOCATE col,row CLS
KEY n,text$
END GOTO linenum
IF cond THEN s [ELSE s] ON x GOTO/GOSUB lines
FOR v=s TO e [STEP n] NEXT [v]
GOSUB linenum RETURN [expr[,expr]]
WHILE cond WEND
DO UNTIL cond
EXIT DATA ...
READ var[,var...] READMAT arr
RESTORE [linenum] DIM name(n)[,...]
CLEARARR name[(idx)][,...] SWAPARR a,b[,c]
DEF FN name(x) = expr TIMER [n,]ms,line | TIMER [n] OFF
TRAP linenum | TRAP OFF RESUME [NEXT | linenum]
SLEEP ms WAITMS ms
DEG RAD
BEEP [ON|OFF] SOUND v,freq,ms[,1]
SHUSH [v] SOUNDPGM n[,arr%[,R|S]]
SOUNDPWM v,pw,lfo SOUNDPRT v,ms
PLAY mml$
LINE x1,y1,x2,y2,ch PLOTCHAR c,r,ch
FILLCELLS c,r,ch,n HLINE x1,x2,y,ch
VLINE x,y1,y2,ch SCROLL ON|OFF
SCROLLX y,h,dir MOVEBLOCK x1,y1,x2,y2,w,h[,ch]
SCROLLXP y,h,px[,cells]
FILLBLOCK x,y,w,h,start[,end]
SAVEBLOCK x,y,w,h,arr% RESTOREBLOCK x,y,w,h,arr%
BORDER ON|OFF
BOX x1,y1,x2,y2,p SETATTRIB c,r,z
PPLOT x,y,p PLINE x0,y0,x1,y1,p[,B|BF]
PCIRCLE x,y,xr,yr,p[,s[,e]][,F]
PFILL x,y,p PPOLY [erase%,] draw%
DOUBLEBUFFER x,y,w,h,on FLIP
DEFCHAR n,b0..b7 RESETCHAR [n]
DEFGFX n,b0..b7 RESETGFX [n]
CHARMODE CHAR|GFX,r[,r2] COPYCHAR src,dst,start[,end]
REVERSE [SCREEN] NORMAL [SCREEN]
WIFI ssid$,pass$ NETCONNECT host$,port
NETDISCONNECT
NETPRINT expr[;...] NETGET var[,...][;]
NETINPUT var[,...][;]
LOAD file SAVE [-]file
DEL file
REN old,new COPY src,dst
CHDIR dir MKDIR dir
CHDIR "SD:" / "NET:" (any name may start SD: or NET:)
(file names in quotes, or a string expression)
FOPEN ch,name$,mode$ FCLOSE ch
FPRINT ch,expr[;...] FINPUT ch,var[,var...]
FGET ch,var FPUT ch,byte
FSEEK ch,delta FREWIND ch
MORE file
VERSION CHUNK arr$,str$[,delim$]
SETTIME h,m,s SETDATE d,m,y
Numeric Functions#
ABS(n) INT(n) SQR(n)
SIN(n) COS(n) TAN(n)
LOG(n) LN(n) RND(min,max)
LEN(s$) ASC(s$) VAL(s$)
DEC("$hh") INSTR(s1$,s2$[,pos])
FRE(0) PRESSED(c,r) KEYDOWN(k)
CHARAT(c,r) GETCHAR(c,r) ATTRIBAT(c,r)
MILLIS() TIME(sel) DATE(sel)
POINT(x,y) CURX() CURY()
RESULT(n) SIZEARR(name,dim) NETCONNECTED()
FBYTES(ch) JOY(n) JOYHIT(n)
CHECKBLOCK(x,y,w,h)
FN name(x)
String Functions#
MID$(s$,start[,len]) LEFT$(s$,n) RIGHT$(s$,n)
CHR$(n) STR$(n) HEX$(n) BIN$(n)
TOUPPER$(s$) TOLOWER$(s$) CHOMP$(s$)
DATE$(sel) TIME$(sel)
WIFI$(n) ERR$(n)
Concatenation: s1$ + s2$Updated 2026-12-04