Skip to content

Commit c537c42

Browse files
authored
Merge pull request #222 from boriel/doc
Doc
2 parents dab3544 + 75ab610 commit c537c42

File tree

268 files changed

+12670
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

268 files changed

+12670
-0
lines changed

doc/docs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../docs

doc/process_wiki.py

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
from bs4 import BeautifulSoup as BS
5+
import sys
6+
import re
7+
import os
8+
9+
RE_CODE = re.compile('<zxbasic>|</zxbasic>|<freebasic>|</freebasic>|<qbasic>|</qbasic>')
10+
RE_INTERNAL_LINK = re.compile(r'\[\[([^]|]+)(\|[^]]+)?\]\]')
11+
RE_EXTERNAL_LINK = re.compile(r'\[(http://[^ ]+) ([^]]+)\]')
12+
13+
14+
def get_file_names(path):
15+
result = set()
16+
for root, dir, files in os.walk(path):
17+
result.update([os.path.basename(x) for x in files])
18+
19+
return result
20+
21+
22+
def link_to_fname(link):
23+
if link.startswith('ZX_BASIC:'):
24+
link = link[9:]
25+
26+
link = link.replace(' ', '_').lower() + '.md'
27+
link = link.replace('released_programs_-_', 'released_programs/')
28+
return link
29+
30+
31+
def write_page(title, text, sha1, already_done):
32+
fname = title.replace(' ', '_').lower().replace('released_programs_-_', 'released_programs/') + '.md'
33+
if fname in already_done:
34+
return
35+
36+
print('Processing {}'.format(fname))
37+
38+
with open(fname, 'wt', encoding='utf-8') as fout:
39+
fout.write('#{}\n\n'.format(title))
40+
started = False
41+
verbatim = False
42+
43+
for line in text.split('\n'):
44+
if line == sha1:
45+
continue
46+
47+
started = started or line == 'text/x-wiki'
48+
if not started or line == 'text/x-wiki':
49+
continue
50+
51+
prefix = ''
52+
if line.startswith(' ') or verbatim:
53+
if not verbatim:
54+
fout.write('```\n')
55+
verbatim = True
56+
elif line and not line.startswith(' '):
57+
fout.write('\n```')
58+
verbatim = False
59+
60+
if not verbatim:
61+
while line and line[0] == line[-1] == '=':
62+
line = line[1:-1]
63+
prefix = prefix + '#'
64+
65+
line = line.replace("'''", '**')
66+
line = line.replace("''", '_')
67+
line = RE_CODE.sub(repl='\n```\n', string=line)
68+
line = line.replace('<tt>', '_').replace('</tt>', '_')
69+
70+
while True:
71+
match = RE_INTERNAL_LINK.search(line)
72+
if not match:
73+
break
74+
lline = list(line)
75+
a, b = match.span()
76+
fname, txt = match.groups()
77+
txt = (txt or fname).lstrip('|')
78+
lline[a: b] = list('[{}]({})'.format(txt, link_to_fname(fname)))
79+
line = ''.join(lline)
80+
81+
while True:
82+
match = RE_EXTERNAL_LINK.search(line)
83+
if not match:
84+
break
85+
lline = list(line)
86+
a, b = match.span()
87+
link, txt = match.groups()
88+
txt = (txt or link).strip()
89+
lline[a: b] = list('[{}]({})'.format(txt, link))
90+
line = ''.join(lline)
91+
92+
line = line.replace('&gt;', '>').replace('&lt;', '<').replace('&amp;', '&')
93+
if line.startswith('*') and line[:2] not in ('* ', '**'):
94+
line = '* {}'.format(line[1:])
95+
96+
fout.write(prefix + line + '\n')
97+
98+
99+
# given your html as the variable 'html'
100+
with open(sys.argv[1], 'rt') as f:
101+
soup = BS(f.read(), "xml")
102+
103+
already_done = get_file_names('./docs')
104+
105+
pages = soup.find_all('page')
106+
for page in pages:
107+
title = page.title.text
108+
if not title.startswith('ZX BASIC:'):
109+
continue
110+
title = title[9:]
111+
write_page(title, page.text, page.sha1.text, already_done)

docs/about.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#About
2+
3+
4+
##About the ZX BASIC Project
5+
6+
ZX BASIC is a [BASIC](http://en.wikipedia.org/wiki/BASIC) ''cross compiler''.
7+
It will compile BASIC programs (in your PC) for your [ZX Spectrum](http://en.wikipedia.org/wiki/Sinclair_ZX_Spectrum).
8+
ZX BASIC is an <abbr title="Software Development Kit">SDK</abbr> entirely written in [python](http://www.python.org).
9+
The SDK is implemented using the [PLY](http://www.dabeaz.com/ply/) (Python Lex/Yacc) compiler tool.
10+
It translates BASIC to Z80 assembler code, so it is easily portable to other Z80 platforms (Amstrad, MSX).
11+
Other non Z80 targets could also be available in the future.
12+
13+
ZX BASIC syntax tries to maintain compatibility as much as possible with
14+
[Sinclair BASIC](http://en.wikipedia.org/wiki/Sinclair_BASIC), it also have many new features, mostly taken from
15+
[FreeBASIC](http://www.freebasic.net/wiki) dialect.
16+
17+
###Platform Availability
18+
Since it is written in python, it is available for many platforms, like Windows, Linux and Mac.
19+
You only need to have python installed on these. For windows, there also is an installable (.MSI) _compiled_
20+
version, which does not need python previously installed.

docs/abs.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#ABS
2+
3+
##Syntax
4+
5+
6+
```
7+
ABS(numericExpression)
8+
```
9+
10+
11+
##Description
12+
13+
Returns the absolute value of the given argument.
14+
Argument must be a numeric expression. Returned value has the same type as the input argument.
15+
16+
##Examples
17+
18+
19+
```
20+
REM Absolute value
21+
LET a = -1
22+
PRINT "Absolute value of a is "; ABS(a)
23+
REM 'Will print 1
24+
```
25+
26+
27+
##Remarks
28+
29+
* This function is 100% Sinclair BASIC Compatible
30+

docs/acs.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#ACS
2+
3+
##Syntax
4+
5+
```
6+
ACS(numericExpression)
7+
```
8+
9+
10+
##Description
11+
12+
Returns the arc cosine value of the given argument.
13+
Argument must be a numeric expression. Returned value type is [Float](types#float.md).
14+
15+
##Examples
16+
17+
```
18+
REM Arc cosine value
19+
PRINT "Arc Cosine value of a is "; ACS(a)
20+
```
21+
22+
23+
##Remarks
24+
25+
* This function is 100% Sinclair BASIC Compatible
26+
* If the given argument type is not float, it will be [converted](cast.md) to float before operating with it.
27+
28+
##See also
29+
30+
* [SIN](sin.md) and [ASN](asn.md)
31+
* [TAN](tan.md) and [ATN](atn.md)
32+
* [COS](cos.md)

docs/architectures/6502.py.md

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#6502.py
2+
3+
```
4+
#!/usr/bin/python
5+
# -*- coding: utf-8 -*-
6+
# vim:ts=4:et:
7+
#- important: this code is not acurated yet - needs fixes
8+
class Opcode(object):
9+
''' Describes opcodes and other info.
10+
'''
11+
def __init__(self, asm, time, size, opcode):
12+
self.asm = asm
13+
self.T = time
14+
self.size = size
15+
self.opcode = opcode
16+
6502SET = {
17+
"BRK": Opcode("BRK", 1, 1, "00"),
18+
"ORA (x,X)": Opcode("ORA (x,X)", 1, 1, "01 XX XX"),
19+
"ORA x": Opcode("ORA x", 1, 1, "05 XX"),
20+
"ASL x": Opcode("ASL x", 1, 1, "06 XX"),
21+
"PHP": Opcode("PHP", 1, 1, "08"),
22+
"ORA #x": Opcode("ORA #x", 1, 1, "09 XX"),
23+
"ASL": Opcode("ASL", 1, 1, "0a"),
24+
"ORA ?": Opcode("ORA ?", 1, 1, "0d XX XX"),
25+
"ASL ?": Opcode("ASL ?", 1, 1, "0e XX XX"),
26+
"BPL x": Opcode("BPL x", 1, 1, "10 XX"),
27+
"ORA (x),Y": Opcode("ORA (x),Y", 1, 1, "11 XX"),
28+
"ORA x,X": Opcode("ORA x,X", 1, 1, "15 XX"),
29+
"ASL x,X": Opcode("ASL x,X", 1, 1, "16 XX"),
30+
"CLC": Opcode("CLC", 1, 1, "18"),
31+
"ORA ?,Y": Opcode("ORA ?,Y", 1, 1, "19 XX XX"),
32+
"ORA ?,X": Opcode("ORA ?,X", 1, 1, "1d XX XX"),
33+
"ASL ?,X": Opcode("ASL ?,X", 1, 1, "1e XX XX"),
34+
"JSR ?": Opcode("JSR ?", 1, 1, "20 XX XX"),
35+
"AND (x,X)": Opcode("AND (x,X)", 1, 1, "21 XX"),
36+
"BIT x": Opcode("BIT x", 1, 1, "24 XX"),
37+
"AND x": Opcode("AND x", 1, 1, "25 XX"),
38+
"ROL x": Opcode("ROL x", 1, 1, "26 XX"),
39+
"PLP": Opcode("PLP", 1, 1, "28"),
40+
"AND #x": Opcode("AND #x", 1, 1, "29 XX"),
41+
"ROL A": Opcode("ROL A", 1, 1, "2a"),
42+
"BIT ?": Opcode("BIT ?", 1, 1, "2c XX XX"),
43+
"AND ?": Opcode("AND ?", 1, 1, "2d XX XX"),
44+
"ROL ?": Opcode("ROL ?", 1, 1, "2e XX XX"),
45+
"BMI x": Opcode("BMI x", 1, 1, "30 XX"),
46+
"AND (x),Y": Opcode("AND (x),Y", 1, 1, "31 XX"),
47+
"AND x,X": Opcode("AND x,X", 1, 1, "35 XX"),
48+
"ROL x,X": Opcode("ROL x,X", 1, 1, "36 XX"),
49+
"SEC": Opcode("SEC", 1, 1, "38"),
50+
"AND ?,Y": Opcode("AND ?,Y", 1, 1, "39 XX XX"),
51+
"AND ?,X": Opcode("AND ?,X", 1, 1, "3d XX XX"),
52+
"ROL ?,X": Opcode("ROL ?,X", 1, 1, "3e XX XX"),
53+
"RTI": Opcode("RTI", 1, 1, "40"),
54+
"EOR (x,X)": Opcode("EOR (x,X)", 1, 1, "41 XX"),
55+
"EOR x": Opcode("EOR x", 1, 1, "45 XX"),
56+
"LSR x": Opcode("LSR x", 1, 1, "46 XX"),
57+
"PHA": Opcode("PHA", 1, 1, "48"),
58+
"EOR #x": Opcode("EOR #x", 1, 1, "49 XX"),
59+
"LSR A": Opcode("LSR A", 1, 1, "4a"),
60+
"JMP ?": Opcode("JMP ?", 1, 1, "4c XX XX"),
61+
"EOR ?": Opcode("EOR ?", 1, 1, "4d XX XX"),
62+
"LSR ?": Opcode("LSR ?", 1, 1, "4e XX XX"),
63+
"BVC x": Opcode("BVC x", 1, 1, "50 XX"),
64+
"EOR (x),Y": Opcode("EOR (x),Y", 1, 1, "51 XX"),
65+
"EOR x,X": Opcode("EOR x,X", 1, 1, "55 XX"),
66+
"LSR x,X": Opcode("LSR x,X", 1, 1, "56 XX"),
67+
"CLI": Opcode("CLI", 1, 1, "58"),
68+
"EOR ?,Y": Opcode("EOR ?,Y", 1, 1, "59 XX XX"),
69+
"EOR ?,X": Opcode("EOR ?,X", 1, 1, "5d XX XX"),
70+
"LSR ?,X": Opcode("LSR ?,X", 1, 1, "5e XX XX"),
71+
"RTS": Opcode("RTS", 1, 1, "60"),
72+
"ADC (x,X)": Opcode("ADC (x,X)", 1, 1, "61 XX"),
73+
"ADC x": Opcode("ADC x", 1, 1, "65 XX"),
74+
"ROR x": Opcode("ROR x", 1, 1, "66 XX"),
75+
"PLA": Opcode("PLA", 1, 1, "68"),
76+
"ADC #x": Opcode("ADC #x", 1, 1, "69 XX"),
77+
"ROR A": Opcode("ROR A", 1, 1, "6a"),
78+
"JMP (?)": Opcode("JMP (?)", 1, 1, "6c XX XX"),
79+
"ADC ?": Opcode("ADC ?", 1, 1, "6d XX XX"),
80+
"ROR ?": Opcode("ROR ?", 1, 1, "6e XX XX"),
81+
"BVS x": Opcode("BVS x", 1, 1, "70 XX"),
82+
"ADC (x),Y": Opcode("ADC (x),Y", 1, 1, "71 XX"),
83+
"ADC x,X": Opcode("ADC x,X", 1, 1, "75 XX"),
84+
"ROR x,X": Opcode("ROR x,X", 1, 1, "76 XX"),
85+
"SEI": Opcode("SEI", 1, 1, "78"),
86+
"ADC ?,Y": Opcode("ADC ?,Y", 1, 1, "79 XX XX"),
87+
"ADC ?,X": Opcode("ADC ?,X", 1, 1, "7d XX XX"),
88+
"ROR ?,X": Opcode("ROR ?,X", 1, 1, "7e XX XX"),
89+
"STA (x,X)": Opcode("STA (x,X)", 1, 1, "81 XX"),
90+
"STY x": Opcode("STY x", 1, 1, "84 XX"),
91+
"STA x": Opcode("STA x", 1, 1, "85 XX"),
92+
"STX x": Opcode("STX x", 1, 1, "86 XX"),
93+
"DEY": Opcode("DEY", 1, 1, "88"),
94+
"TXA": Opcode("TXA", 1, 1, "8a"),
95+
"STY ?": Opcode("STY ?", 1, 1, "8c XX XX"),
96+
"STA ?": Opcode("STA ?", 1, 1, "8d XX XX"),
97+
"STX ?": Opcode("STX ?", 1, 1, "8e XX XX"),
98+
"BCC x": Opcode("BCC x", 1, 1, "90 XX"),
99+
"STA (x),Y": Opcode("STA (x),Y", 1, 1, "91 XX"),
100+
"STY x,X": Opcode("STY x,X", 1, 1, "94 XX"),
101+
"STA x,X": Opcode("STA x,X", 1, 1, "95 XX"),
102+
"STX x,Y": Opcode("STX x,Y", 1, 1, "96 XX"),
103+
"TYA": Opcode("TYA", 1, 1, "98"),
104+
"STA ?,Y": Opcode("STA ?,Y", 1, 1, "99 XX XX"),
105+
"TXS": Opcode("TXS", 1, 1, "9a"),
106+
"STA ?,X": Opcode("STA ?,X", 1, 1, "9d XX XX"),
107+
"LDY #x": Opcode("LDY #x", 1, 1, "a0 XX"),
108+
"LDA (x,X)": Opcode("LDA (x,X)", 1, 1, "a1 XX"),
109+
"LDX #x": Opcode("LDX #x", 1, 1, "a2 XX"),
110+
"LDY x": Opcode("LDY x", 1, 1, "a4 XX"),
111+
"LDA x": Opcode("LDA x", 1, 1, "a5 XX"),
112+
"LDX x": Opcode("LDX x", 1, 1, "a6 XX"),
113+
"TAY": Opcode("TAY", 1, 1, "a8"),
114+
"LDA #x": Opcode("LDA #x", 1, 1, "a9 XX"),
115+
"TAX": Opcode("TAX", 1, 1, "aa"),
116+
"LDY ?": Opcode("LDY ?", 1, 1, "ac XX XX"),
117+
"LDA ?": Opcode("LDA ?", 1, 1, "ad XX XX"),
118+
"LDX ?": Opcode("LDX ?", 1, 1, "ae XX XX"),
119+
"BCS x": Opcode("BCS x", 1, 1, "b0 XX"),
120+
"LDA (x),Y": Opcode("LDA (x),Y", 1, 1, "b1"),
121+
"LDY x,X": Opcode("LDY x,X", 1, 1, "b4"),
122+
"LDA x,X": Opcode("LDA x,X", 1, 1, "b5"),
123+
"LDX x,Y": Opcode("LDX x,Y", 1, 1, "b6"),
124+
"CLV": Opcode("CLV", 1, 1, "b8"),
125+
"LDA ?,Y": Opcode("LDA ?,Y", 1, 1, "b9"),
126+
"TSX": Opcode("TSX", 1, 1, "ba"),
127+
"LDY ?,X": Opcode("LDY ?,X", 1, 1, "bc"),
128+
"LDA ?,X": Opcode("LDA ?,X", 1, 1, "bd"),
129+
"LDX ?,Y": Opcode("LDX ?,Y", 1, 1, "be"),
130+
"CPY #x": Opcode("CPY #x", 1, 1, "c0 XX"),
131+
"CMP (x,X)": Opcode("CMP (x,X)", 1, 1, "c1 XX"),
132+
"CPY x": Opcode("CPY x", 1, 1, "c4 XX"),
133+
"CMP x": Opcode("CMP x", 1, 1, "c5 XX"),
134+
"DEC x": Opcode("DEC x", 1, 1, "c6 XX"),
135+
"INY": Opcode("INY", 1, 1, "c8"),
136+
"CMP #x": Opcode("CMP #x", 1, 1, "c9 XX"),
137+
"DEX": Opcode("DEX", 1, 1, "ca"),
138+
"CPY ?": Opcode("CPY ?", 1, 1, "cc XX XX"),
139+
"CMP ?": Opcode("CMP ?", 1, 1, "cd XX XX"),
140+
"DEC ?": Opcode("DEC ?", 1, 1, "ce XX XX"),
141+
"BNE x": Opcode("BNE x", 1, 1, "d0 XX"),
142+
"CMP (x),Y": Opcode("CMP (x),Y", 1, 1, "d1 XX"),
143+
"CMP x,X": Opcode("CMP x,X", 1, 1, "d5 XX"),
144+
"DEC x,X": Opcode("DEC x,X", 1, 1, "d6 XX"),
145+
"CLD": Opcode("CLD", 1, 1, "d8"),
146+
"CMP ?,Y": Opcode("CMP ?,Y", 1, 1, "d9"),
147+
"CMP ?,X": Opcode("CMP ?,X", 1, 1, "dd"),
148+
"DEC ?,X": Opcode("DEC ?,X", 1, 1, "de"),
149+
"CPX #x": Opcode("CPX #x", 1, 1, "e0 XX"),
150+
"SBC (x,X)": Opcode("SBC (x,X)", 1, 1, "e1 XX"),
151+
"CPX x": Opcode("CPX x", 1, 1, "e4 XX"),
152+
"SBC x": Opcode("SBC x", 1, 1, "e5 XX"),
153+
"INC x": Opcode("INC x", 1, 1, "e6 XX"),
154+
"INX": Opcode("INX", 1, 1, "e8"),
155+
"SBC #x": Opcode("SBC #x", 1, 1, "e9 XX"),
156+
"NOP": Opcode("NOP", 1, 1, "ea"),
157+
"CPX ?": Opcode("CPX ?", 1, 1, "ec XX XX"),
158+
"SBC ?": Opcode("SBC ?", 1, 1, "ed XX XX"),
159+
"INC ?": Opcode("INC ?", 1, 1, "ee XX XX"),
160+
"BEQ x": Opcode("BEQ x", 1, 1, "f0 XX"),
161+
"SBC (x),Y": Opcode("SBC (x),Y", 1, 1, "f1 XX"),
162+
"SBC x,X": Opcode("SBC x,X", 1, 1, "f5 XX"),
163+
"INC x,X": Opcode("INC x,X", 1, 1, "f6 XX"),
164+
"SED": Opcode("SED", 1, 1, "f8"),
165+
"SBC ?,Y": Opcode("SBC ?,Y", 1, 1, "f9 XX XX"),
166+
"SBC ?,X": Opcode("SBC ?,X", 1, 1, "fd XX XX"),
167+
"INC ?,X": Opcode("INC ?,X", 1, 1, "fe XX XX"),
168+
169+
}
170+
171+

0 commit comments

Comments
 (0)