Switch to new version (this old version is deprecated)

Phosphor Microcomputer (Under Construction)

A browser-based microcomputer inspired by:

Instructions

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.

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.

You can type a Lua program in the code editor (CTRL+ALT+1) and in the console (CTRL+ALT+`) type 'run' to run it.

Type 'load hello' then 'run' to load and run this simple demo text program:

-- hello (demo)
write('What is your name? ')
name = read()
print('Hello', name)

Type 'load bounce' then 'run' to load and run this simple demo graphics program:

-- 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

Type 'help' for more commands.

These graphics syscalls work as expected:

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

Keyboard state can be obtained like:

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

The 62 key names are (currently):

- 0 to 9
- ` - = [ ] \ ; ' , . /
- a to z
- space tab enter backspace capslock
- up down left right
- lctrl lshift lalt
- rctrl rshift ralt

Memory access:

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)

Please note that at this point, nothing finalized, everything is subject to change.