Skip to content

Commit c0807a6

Browse files
authored
Merge pull request #336 from boriel/docs
Docs
2 parents 330a939 + 7620234 commit c0807a6

File tree

4 files changed

+211
-1
lines changed

4 files changed

+211
-1
lines changed

docs/cls.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#CLS
2+
3+
##Syntax
4+
5+
```
6+
CLS
7+
```
8+
9+
##Description
10+
11+
`CLS` is short for *CLear Screen*, and will do just that: it will clear the screen, setting the background
12+
with the current [PAPER](paper.md) color, and placing the Screen Cursor at (0, 0) - screen top-leftmost corner.
13+
14+
15+
##Examples
16+
17+
```
18+
REM sets the screen black, and INK white
19+
BORDER 0: PAPER 0: INK 7
20+
CLS
21+
PRINT "White text on black background"
22+
```
23+
24+
25+
##Remarks
26+
27+
* This sentence is compatible with Sinclair BASIC
28+
29+
##See also
30+
31+
* [PRINT](print.md)
32+
* [AT](at.md)
33+
* [PAPER](paper.md)
34+
* [BORDER](border.md)
35+
* [INVERSE](inverse.md)
36+
* [INK](ink.md)
37+
* [ITALIC](italic.md)
38+
* [BOLD](bold.md)
39+
* [OVER](over.md)

docs/print.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#PRINT
2+
3+
##Syntax
4+
5+
```
6+
PRINT [<item>][;]
7+
```
8+
9+
##Description
10+
11+
`PRINT` is a sentence used to output information on the screen. The ZX Spectrum screen is divided in 24 rows (numbered
12+
from 0 to 23), and 32 columns (numbered from 0 to 31). So it's composed of 24 x 32 = 96 cells. Cells are referred by
13+
its coordinate (row, column), being (0, 0) the top-leftmost cell, and (23, 31) the bottom-rightmost one.
14+
15+
There's a _hidden cursor_ on the screen that points to the coordinate where the next character will be printed.
16+
Each time something is printed, a _carriage return_ is also printed and the screen cursor is advanced to
17+
the next line (row):
18+
19+
```
20+
PRINT "I'M ON ONE LINE"
21+
PRINT "I'M ON THE NEXT ONE"
22+
```
23+
24+
If you don't want this to happen, you can add a semicolon (;) at the end of the `PRINT` sentence, and the next
25+
printed expression will still be on the same line:
26+
27+
```
28+
PRINT "I'M ON ONE LINE";
29+
PRINT "... AND I'M ALSO ON THE SAME LINE"
30+
PRINT "AND I'M ON A NEW LINE"
31+
```
32+
Notice the first `PRINT` ends with a semicolon to avoid _carriage return_. Executing a single `PRINT` will just
33+
advance the cursor to the next line.
34+
35+
> **NOTE**: when the cursor reaches the end of the screen, it will **scroll upwards** all rows 1 position.
36+
37+
Let's prints numbers from 0 to 25 and see what happens:
38+
39+
```
40+
CLS: REM Clears screeen and puts the cursor at the top-leftmost corner
41+
FOR i = 0 TO 25
42+
PRINT i
43+
NEXT i
44+
```
45+
You'll see that number 0 and 1 are gone (they were shifted up and went out of the screen).
46+
47+
> **NOTE**: When the screen is cleared with [CLS](cls.md), the cursor is set to its default position (0, 0),
48+
> that is, the top-leftmost screen corner.
49+
50+
`PRINT` can print everything that is a _single_ expression (also called an _item_).
51+
That is, strings (like in the previous example), numbers, variable values, and array elements
52+
(it can not print an entire array; that's not a `single` element but a collection):
53+
54+
For example:
55+
56+
```
57+
LET a = 5
58+
PRINT "Variable 'a' contains the value: ";
59+
PRINT a
60+
```
61+
62+
Indeed, if you want to chain several expressions one after another you can _chain_ them in a single PRINT sentence
63+
using semicolons:
64+
```
65+
LET a = 5
66+
PRINT "Variable 'a' contains the value: "; a
67+
```
68+
69+
## Changing the print position
70+
You can change the current _cursor_ position using the [AT](at.md) modifier:
71+
72+
```
73+
PRINT AT 5, 0; "This message starts at ROW 5"
74+
PRINT AT 10, 10; "This message starts at ROW 10, COLUMN 10"
75+
```
76+
77+
Again, you can chain all `PRINT` _items_ using semicolon:
78+
79+
```
80+
PRINT AT 5, 0; "ROW 5"; AT 10, 10; "ROW 10, COLUMN 10"
81+
```
82+
83+
## Changing appearance
84+
You can temporarily override the aspect of the items printed using them inline:
85+
86+
```
87+
CLS
88+
FOR i = 1 to 7
89+
PRINT AT i, 0; PAPER 0; INK i; "PRINT AT ROW "; i; " WITH INK "; i
90+
NEXT i
91+
```
92+
93+
See the related commands section for further info.
94+
95+
##Examples
96+
97+
```
98+
REM Prints a letter in the 10th row of the screen moving from left to right
99+
CLS
100+
FOR i = 0 TO 31
101+
PRINT AT 10, i; "A"
102+
PAUSE 10
103+
PRINT AT 10, i; " ": REM Erases the letter
104+
NEXT i
105+
```
106+
107+
108+
##Remarks
109+
110+
* This sentence is compatible with Sinclair BASIC but _expands_ it, since it allows printing at rows 22 and 23
111+
(all 24 rows are available to the programmer). Traditionally, Sinclair BASIC only allows to print at rows 0..21.
112+
* You can use [ITALIC](italic.md) and [BOLD](bold.md) modifiers (not available in Sinclair BASIC)
113+
114+
##See also
115+
116+
* [CLS](cls.md)
117+
* [AT](at.md)
118+
* [PAPER](paper.md)
119+
* [BORDER](border.md)
120+
* [INVERSE](inverse.md)
121+
* [INK](ink.md)
122+
* [ITALIC](italic.md)
123+
* [BOLD](bold.md)
124+
* [OVER](over.md)

docs/return.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#RESTORE
2+
3+
4+
##Syntax
5+
```
6+
RETURN [<expr>]
7+
```
8+
**RETURN** statement is used in 3 cases:
9+
10+
1. When returning from a [GO SUB](gosub.md) sentence
11+
2. When returning (exiting) from a [SUB](sub.md) (a subroutine)
12+
3. When returning (exiting) from a [FUNCTION](function.md). In this case a return value must be specified.
13+
14+
15+
Returns in the global scope (that is, outside any function or sub) are treated as return from [GO SUB](gosub.md).
16+
Otherwise they are considered as returning from the function or sub they are into.
17+
18+
> **WARNING**: Using RETURN in global scope without a GOSUB will mostly crash your program. <br>
19+
> Use `--stack-check` if you suspect you have this bug, to detect it.
20+
21+
### Example with GO SUB
22+
23+
```
24+
10 LET number = 10
25+
20 GOSUB 1000 : REM calls the subroutine
26+
30 LET number = 20
27+
40 GOSUB 1000 : REM calls the subroutine again
28+
100 END : REM the program must end here to avoid entering the subroutine without using GOSUB
29+
1000 REM Subroutine that prints number + 1
30+
1010 PRINT "number + 1 is "; number + 1
31+
1020 RETURN : REM return to the caller
32+
```
33+
34+
This will output:
35+
36+
```
37+
number + 1 is 11
38+
number + 1 is 21
39+
```
40+
41+
##Remarks
42+
* This statement is Sinclair BASIC compatible.
43+
44+
##See also
45+
* [GO SUB](gosub.md)
46+
* [FUNCTION](function.md)
47+
* [SUB](sub.md)

library/memcopy.bas

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ end sub
5959
'
6060
' Copies block of memory from source to dest.
6161
' Source and destiny blocks should not overlap.
62-
' This sub is slighly faster than memmove
62+
' This sub is slightly faster than memmove
6363
' ----------------------------------------------------------------
6464
sub fastcall MemCopy(source as uinteger, dest as uinteger, length as uinteger)
6565
asm

0 commit comments

Comments
 (0)