1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-09-30 02:12:34 +03:00
iris/source/bsquare.ccp
2010-01-31 09:26:23 +01:00

44 lines
933 B
COBOL

#pypp 0
#include <iris.hh>
#include <devices.hh>
static unsigned *framebuffer
static int const r = 10
static int colour
void square (int x, int y, bool print):
for int ty = y - r; ty < y + r; ++ty:
if ty < 0 || ty >= 240:
continue
for int tx = x - r; tx < x + r; ++tx:
if tx < 0 || tx >= 320:
continue
framebuffer[ty * 320 + tx] = (print ? colour : 0)
Kernel::Num start ():
Kernel::my_parent.init_done ()
colour = 0xffffff
framebuffer = (unsigned *)0x15000
Display display = Kernel::my_parent.get_device <Display> (0x10001)
int x = r, y = r, dx = 3, dy = 3
Kernel::Cap eof = Kernel::my_receiver.create_capability (0)
while true:
display.set_eof_cb (eof)
Kernel::wait ()
square (x, y, false)
x += dx
y += dy
if y + r >= 240:
dy = -dy
y = 240 - r
if x - r < 0:
x = r
dx = -dx
if x + r >= 320:
x = 320 - r
dx = -dx
if y - r < 0:
y = r
dy = -dy
square (x, y, true)