1
0
mirror of git://projects.qi-hardware.com/iris.git synced 2024-11-17 03:26:14 +02:00
iris/userspace/application/bsquare.ccp

61 lines
1.7 KiB
Plaintext
Raw Normal View History

2010-01-31 10:26:23 +02:00
#pypp 0
2010-02-06 00:15:58 +02:00
// Iris: micro-kernel for a capability-based operating system.
// source/bsquare.ccp: Floating square demo.
// Copyright 2009 Bas Wijnen <wijnen@debian.org>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
2010-01-31 10:26:23 +02:00
#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)
Iris::Num start ():
Iris::my_parent.init_done ()
2010-02-06 00:15:58 +02:00
colour = 0xffff00
2010-01-31 10:26:23 +02:00
framebuffer = (unsigned *)0x15000
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> (0x10001)
2010-01-31 10:26:23 +02:00
int x = r, y = r, dx = 3, dy = 3
Iris::Cap eof = Iris::my_receiver.create_capability (0)
2010-01-31 10:26:23 +02:00
while true:
display.set_eof_cb (eof)
Iris::wait ()
2010-01-31 10:26:23 +02:00
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)