Skip to content

Commit 3e54f79

Browse files
committed
doc: add Docs
1 parent 69f1c64 commit 3e54f79

File tree

5 files changed

+204
-1
lines changed

5 files changed

+204
-1
lines changed

docs/library.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ Will print 64 characters to a line (grid, not proportional), and 32 lines of tex
126126
Upping the standard 768 character screen to 2048 characters of text on one screen at once.
127127
Works in a similar way to print42. This version uses screen tables.
128128

129-
####Compression / Decompression Library
129+
#### Memory Banking
130+
131+
* [memorybank.bas](library/memorybank.md)
132+
<br /> Library to access RAM banks and get advantage of extra RAM in 128k models.
133+
134+
#### Compression / Decompression Library
130135

131136
* [megaLZDepack.bas](library/megalz.bas.md)
132137
<br /> Routine wrapping the megaLZ decompression algorithm.

docs/library/memorybank.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# MemoryBank
2+
3+
The MemoryBank library allows you to manage paged memory on 128K and later/compatible models.
4+
5+
This library includes three commands:
6+
- [SetBank](memorybank/setbank.md): Sets the specified bank to memory location $c000.
7+
- [GetBank](memorybank/getbank.md): Returns the memory bank that is located at memory location $c000.
8+
- [SetCodeBank](memorybank/setcodebank.md): Copies the specified memory bank to location $8000
9+
10+
Only works on 128K and later/compatible models.
11+
12+
**Danger:** If our program exceeds the address $c000 it may cause problems, use this library at your own risk.
13+
14+
15+
## Menory banks
16+
- $c000 > Bank 0 to Bank 7
17+
- $8000 > Bank 2 (fixed)
18+
- $4000 > Bank 5 (screen)
19+
- $0000 > ROM
20+
21+
Banks 2 and 5 are permanently fixed at addresses $8000 and $4000, so it is not common to use them.
22+
23+
Banks 1, 3, 5 and 7 are banks in contention with the ULA, their use is not recommended in processes requiring maximum speed.
24+
25+
## See also
26+
- [SetBank](memorybank/setbank.md)
27+
- [GetBank](memorybank/getbank.md)
28+
- [SetCodeBank](memorybank/setcodebank.md)

docs/library/memorybank/getbank.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# GetBank
2+
3+
## Syntax
4+
5+
```
6+
#include <memorybank.bas>
7+
8+
PRINT "Current bank at $c000: ";GetBank()
9+
```
10+
11+
## Description
12+
Returns the memory bank located at $c000 based on the system variable BANKM.
13+
14+
Only works on 128K and compatible models.
15+
16+
**Danger:** If our program exceeds the address $c000 it may cause problems, use this function at your own risk.
17+
18+
19+
## Memory banks
20+
- $c000 > Bank 0 to Bank 7
21+
- $8000 > Bank 2 (fixed)
22+
- $4000 > Bank 5 (screen)
23+
- $0000 > ROM
24+
25+
Banks 2 and 5 are permanently fixed at addresses $8000 and $4000, so it is not common to use them.
26+
Banks 1, 3, 5 and 7 are banks in contention with the ULA, their use is not recommended in processes requiring maximum speed.
27+
28+
29+
## Examples
30+
31+
```basic
32+
#include "memorybank.bas"
33+
34+
DIM n AS UByte
35+
36+
' Fill banks with data
37+
FOR n = 0 TO 7
38+
SetBank(n)
39+
PRINT AT n,0;"Bank: ";n;
40+
POKE $c000,n
41+
PRINT " > ";GetBank();
42+
NEXT n
43+
44+
' Read banks
45+
FOR n = 0 TO 7
46+
SetBank(n)
47+
PRINT AT n,15;PEEK($c000);
48+
NEXT n
49+
```
50+
51+
## See also
52+
- [SetBank](setbank.md)
53+
- [SetCodeBank](setcodebank.md)

docs/library/memorybank/setbank.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# SetBank
2+
3+
## Syntax
4+
5+
```
6+
#include <memorybank.bas>
7+
8+
SetBank(3)
9+
```
10+
11+
## Description
12+
Place the bank indicated by bankNumber in the memory slot between $c000 and $ffff and updates the system variable BANKM.
13+
14+
Only works on 128K and compatible models.
15+
16+
**Danger:** If our program exceeds the address $c000 it may cause problems, use this function at your own risk.
17+
18+
19+
## Memory banks
20+
- $c000 > Bank 0 to Bank 7
21+
- $8000 > Bank 2 (fixed)
22+
- $4000 > Bank 5 (screen)
23+
- $0000 > ROM
24+
25+
Banks 2 and 5 are permanently fixed at addresses $8000 and $4000, so it is not common to use them.
26+
Banks 1, 3, 5 and 7 are banks in contention with the ULA, their use is not recommended in processes requiring maximum speed.
27+
28+
29+
## Examples
30+
31+
```basic
32+
#include <memorybank.bas>
33+
34+
DIM n AS UByte
35+
36+
' Fill banks with data
37+
FOR n = 0 TO 7
38+
SetBank(n)
39+
PRINT AT n,0;"Bank: ";n;
40+
POKE $c000,n
41+
NEXT n
42+
43+
' Read banks
44+
FOR n = 0 TO 7
45+
SetBank(n)
46+
PRINT AT n,10;PEEK($c000);
47+
NEXT n
48+
```
49+
50+
## See also
51+
- [GetBank](getbank.md)
52+
- [SetCodeBank](setcodebank.md)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# SetCodeBank
2+
3+
## Syntax
4+
5+
```
6+
#include <memorybank.bas>
7+
8+
SetCodeBank(3)
9+
```
10+
11+
## Description
12+
Place the bank indicated by bankNumber in the memory slot between $c000 and $ffff and updates the system variable BANKM.
13+
This command is applicable to the architecture described in chapter 14 of the Boriel Basic for ZX Spectrum book.
14+
15+
Only works on 128K and compatible models.
16+
17+
**Danger:** If our program exceeds the address $c000 it may cause problems, use this function at your own risk.
18+
Bank 2 is destroyed in this operation, apart from the contents of $8000 to $bfff, so it should not be used.
19+
20+
21+
## Memory banks
22+
- $c000 > Bank 0 to Bank 7
23+
- $8000 > Bank 2 (fixed)
24+
- $4000 > Bank 5 (screen)
25+
- $0000 > ROM
26+
27+
Banks 2 and 5 are permanently fixed at addresses $8000 and $4000, so it is not common to use them.
28+
Banks 1, 3, 5 and 7 are banks in contention with the ULA, their use is not recommended in processes requiring maximum speed.
29+
30+
31+
## Examples
32+
33+
```
34+
#include <memorybank.bas>
35+
36+
DIM n, b AS UByte
37+
38+
' Fill banks with data
39+
FOR n = 0 TO 7
40+
SetBank(n)
41+
PRINT AT n,0;"Bank: ";n;
42+
POKE $c000,n
43+
NEXT n
44+
45+
' SetCodeBank
46+
FOR n = 0 TO 7
47+
PRINT AT n+1,16;">";n;
48+
SetCodeBank(n)
49+
IF n = 2 THEN
50+
PRINT ">SKIP";
51+
ELSE
52+
b = PEEK($8000)
53+
PRINT ">";b;
54+
IF b = n THEN
55+
PRINT ">OK";
56+
ELSE
57+
PRINT ">ERROR";
58+
END IF
59+
END IF
60+
NEXT n
61+
```
62+
63+
## See also
64+
- [SetBank](setbank.md)
65+
- [GetBank](getbank.md)

0 commit comments

Comments
 (0)