/
index.html
129 lines (96 loc) · 3.56 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html>
<body>
<input type='file' style='display:none'/>
<!-- https://pixelsvsbytes.com/2013/02/js-require-for-browsers-better-faster-stronger/ -->
<script src='require.min.js'></script>
<scriptx src='page-bsp.js'></scriptx>
<script>
const bsp = Tarp.require('./bsp.js');
const phosphor = bsp.newPhosphor();
phosphor.reboot();
</script>
<p>Switch to <a href="../phosphor/">new</a> version (this old version is deprecated)</p>
<h1>Phosphor Microcomputer (Under Construction)</h1>
<p>A browser-based microcomputer inspired by:</p>
<ul>
<li>Commodore 64 (BASIC programming language and games)</li>
<li>LOGO (programmable pen turtle graphics)</li>
<li>Unix / Linux / Raspberry Pi (terminal, shell, filesystem, text processing)</li>
<li>LÖVE (Lua engine for 2D games)</li>
<li>PICO-8 (and similar fantasy consoles with builtin editors)</li>
<li>Game Boy (simple games with simple controls)</li>
</ul>
<h1>Instructions</h1>
<p>Type commands in the console (command line). Type 'scale n' where n is an integer (1, 2, 3, ...) to change the scale of the display; 'scale 0' means fullscreen. Type 'reboot' or reload the page to reboot the microcomputer.</p>
<p>Hit ESCAPE to toggle edit mode on and off, or CTRL+ALT+1 through CTRL+ALT+5 to go directly to the editors (code, sprite, map, sound, music; only the code editor works right now). Hit CTRL+ALT+` to go directly to the console.</p>
<p>You can type a Lua program in the code editor (CTRL+ALT+1) and in the console (CTRL+ALT+`) type 'run' to run it.</p>
<p>Type 'load hello' then 'run' to load and run this simple demo text program:</p>
<pre>
-- hello (demo)
write('What is your name? ')
name = read()
print('Hello', name)
</pre>
<p>Type 'load bounce' then 'run' to load and run this simple demo graphics program:</p>
<pre>
-- bounce (demo)
r,d = 4,8
x,y = 96,64
dx,dy = 2,1
function update()
x,y = x+dx,y+dy
if x < d or 192-d < x then dx = -dx end
if y < d or 128-d < y then dy = -dy end
end
function draw()
clear(5)
rect(x-r, y-r, d, d, 11)
end
</pre>
<p>Type 'help' for more commands.</p>
<p>These graphics syscalls work as expected:</p>
<pre>
clear(c) -- clear screen
pget(x, y) -- get pixel at x,y
pset(x, y, c) -- set pixel at x,y
line(x1, y1, x2, y2, c) -- draw line from x1,y1 to x2,y2
rect(x, y, w, h, c1, c2) -- draw rect at x,y with size w,h
circle(x, y, r, c1, c2) -- draw circle at x,y with radius r
char(ch, x, y, c1, c2) -- draw char ch at x,y
text(str, x, y, c1, c2) -- draw string str at x,y
sprite(n, x, y) -- draw sprite n at x,y
sget(n, x, y) -- get pixel from sprite n
sset(n, x, y, c) -- set pixel in sprite n
map(x, y, mx, my, mw, mh) -- draw map (cells at mx,my size mw,mh) at x,y
mget(x, y) -- get map value at cell x,y
mset(x, y, n) -- set map value at cell x,y
</pre>
<p>Keyboard state can be obtained like:</p>
<pre>
keyp('a') -- true the first frame key 'a' is pressed
keyr('a') -- true the first frame key 'a' is released
key('a') -- true all frames key 'a' is being pressed
</pre>
<p>The 62 key names are (currently):</p>
<pre>
- 0 to 9
- ` - = [ ] \ ; ' , . /
- a to z
- space tab enter backspace capslock
- up down left right
- lctrl lshift lalt
- rctrl rshift ralt
</pre>
<p>Memory access:</p>
<pre>
peek(addr) -- get byte
poke(addr, val) -- set byte to val
memset(addr, len, val) -- set len bytes of memory to val
memcopy(addr, len, addr_from) -- copy len bytes of memory
memread(addr, len) -- get len bytes (as hex string)
memwrite(addr, str) -- set bytes (from hex string)
</pre>
<p>Please note that at this point, nothing finalized, everything is subject to change.</p>
</body>
</html>