2010-01-24 22:34:24 +02:00
|
|
|
#pypp 0
|
|
|
|
#include <iris.hh>
|
|
|
|
#include <devices.hh>
|
|
|
|
|
|
|
|
static unsigned *framebuffer
|
|
|
|
static int const r = 10
|
2010-01-30 10:21:56 +02:00
|
|
|
static int colour
|
2010-01-24 22:34:24 +02:00
|
|
|
|
|
|
|
void ball (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
|
|
|
|
if (x - tx) * (x - tx) + (y - ty) * (y - ty) > r * r:
|
|
|
|
continue
|
2010-01-30 10:21:56 +02:00
|
|
|
framebuffer[ty * 320 + tx] = (print ? colour : 0)
|
2010-01-24 22:34:24 +02:00
|
|
|
|
|
|
|
Kernel::Num start ():
|
|
|
|
Kernel::my_parent.init_done ()
|
2010-01-30 10:21:56 +02:00
|
|
|
colour = 0xffffff
|
2010-01-24 22:34:24 +02:00
|
|
|
framebuffer = (unsigned *)0x15000
|
2010-01-30 10:21:56 +02:00
|
|
|
Display display = Kernel::my_parent.get_device <Display> (0x10000)
|
2010-01-24 22:34:24 +02:00
|
|
|
int x = r, y = r, dx = 3, dy = 0
|
|
|
|
Kernel::Cap eof = Kernel::my_receiver.create_capability (0)
|
|
|
|
while true:
|
|
|
|
display.set_eof_cb (eof)
|
|
|
|
Kernel::wait ()
|
|
|
|
ball (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 == 240 - r && dy == 0:
|
|
|
|
dy = -21
|
|
|
|
++dy
|
|
|
|
ball (x, y, true)
|