Root/
Source at commit 12bfb32 created 13 years 10 months ago. By Bas Wijnen, make things work with unfinished new startup procedure | |
---|---|
1 | #pypp 0 |
2 | // Iris: micro-kernel for a capability-based operating system. |
3 | // source/bsquare.ccp: Floating square demo. |
4 | // Copyright 2009 Bas Wijnen <wijnen@debian.org> |
5 | // |
6 | // This program is free software: you can redistribute it and/or modify |
7 | // it under the terms of the GNU General Public License as published by |
8 | // the Free Software Foundation, either version 3 of the License, or |
9 | // (at your option) any later version. |
10 | // |
11 | // This program is distributed in the hope that it will be useful, |
12 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | // GNU General Public License for more details. |
15 | // |
16 | // You should have received a copy of the GNU General Public License |
17 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | #include <iris.hh> |
20 | #include <devices.hh> |
21 | |
22 | static unsigned *framebuffer |
23 | static int const r = 10 |
24 | static int colour |
25 | |
26 | void square (int x, int y, bool print): |
27 | for int ty = y - r; ty < y + r; ++ty: |
28 | if ty < 0 || ty >= 240: |
29 | continue |
30 | for int tx = x - r; tx < x + r; ++tx: |
31 | if tx < 0 || tx >= 320: |
32 | continue |
33 | framebuffer[ty * 320 + tx] = (print ? colour : 0) |
34 | |
35 | Iris::Num start (): |
36 | Iris::my_parent.init_done () |
37 | colour = 0xffff00 |
38 | framebuffer = (unsigned *)0x15000 |
39 | Iris::Display display = Iris::my_parent.get_device <Iris::Display> (0x10001) |
40 | int x = r, y = r, dx = 3, dy = 3 |
41 | Iris::Cap eof = Iris::my_receiver.create_capability (0) |
42 | while true: |
43 | display.set_eof_cb (eof) |
44 | Iris::wait () |
45 | square (x, y, false) |
46 | x += dx |
47 | y += dy |
48 | if y + r >= 240: |
49 | dy = -dy |
50 | y = 240 - r |
51 | if x - r < 0: |
52 | x = r |
53 | dx = -dx |
54 | if x + r >= 320: |
55 | x = 320 - r |
56 | dx = -dx |
57 | if y - r < 0: |
58 | y = r |
59 | dy = -dy |
60 | square (x, y, true) |
61 |
Branches:
master