mirror of
git://projects.qi-hardware.com/iris.git
synced 2024-11-17 01:40:36 +02:00
61 lines
1.7 KiB
COBOL
61 lines
1.7 KiB
COBOL
#pypp 0
|
|
// 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/>.
|
|
|
|
#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 ()
|
|
colour = 0xffff00
|
|
framebuffer = (unsigned *)0x15000
|
|
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> (0x10001)
|
|
int x = r, y = r, dx = 3, dy = 3
|
|
Iris::Cap eof = Iris::my_receiver.create_capability (0)
|
|
while true:
|
|
display.set_eof_cb (eof)
|
|
Iris::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)
|