From fb85d0f1d7bbb4d541f338809f7f5bc7f623b63a Mon Sep 17 00:00:00 2001 From: Bas Wijnen Date: Fri, 5 Feb 2010 23:15:58 +0100 Subject: [PATCH] working demo --- boot-programs/init.ccp | 32 +++++++++++++++++++++----------- memory.ccp | 17 +++++++++++++++++ source/ball.ccp | 19 ++++++++++++++++++- source/bsquare.ccp | 19 ++++++++++++++++++- source/display-emu.ccp | 17 +++++++++++++++++ 5 files changed, 91 insertions(+), 13 deletions(-) diff --git a/boot-programs/init.ccp b/boot-programs/init.ccp index dd4bafe..c9a8cb2 100644 --- a/boot-programs/init.ccp +++ b/boot-programs/init.ccp @@ -418,6 +418,21 @@ static void get_device (): Kernel::panic (0) Kernel::free_cap (reply) +static void draw_ball (): + int const r = 50 + for int y = -r; y < r; ++y: + for int x = -r; x < r; ++x: + if x * x + y * y > r * r: + ((unsigned *)0x15000)[(120 + y) * 320 + 160 + x] = 0x000000 + else: + ((unsigned *)0x15000)[(120 + y) * 320 + 160 + x] = 0x3f30ff + +static void draw_square (): + int const r = 50 + for int y = -r; y < r; ++y: + for int x = -r; x < r; ++x: + ((unsigned *)0x15000)[(120 + y) * 320 + 160 + x] = 0xffff00 + Kernel::Num start (): // Wait for the debugging device to be active, in case there is one. Kernel::schedule () @@ -471,6 +486,7 @@ Kernel::Num start (): Kernel::panic (0, "no display") Kernel::Caps display_caps = display_dev->dev.create_user (Kernel::my_memory, 0, 0x15000) Display display = display_caps.get (0) + draw_ball () Dev *keyboard_dev = Dev::find (Keyboard::ID, 0) if !keyboard_dev: Kernel::panic (0, "no keyboard") @@ -533,7 +549,9 @@ Kernel::Num start (): Kernel::panic (Kernel::recv.data[0].l, "invalid operation from child") break case KEYBOARD: - if in_system && Kernel::recv.data[0].l == (Key::ENTER | Keyboard::RELEASE): + if !in_system: + break + if Kernel::recv.data[0].l == (Key::ENTER | Keyboard::RELEASE): for Dev *d = Dev::devs; d; d = d->next: if d->idx != 0: continue @@ -549,24 +567,16 @@ Kernel::Num start (): break if Kernel::recv.data[0].l & Keyboard::RELEASE: continue - unsigned const r = 50 unsigned which = 0 switch Kernel::recv.data[0].l: case Key::VOLUME_DOWN: // Set ball. - for int y = -r; y < r; ++y: - for int x = -r; x < r; ++x: - if x * x + y * y > r * r: - ((unsigned *)0x15000)[(120 + y) * 320 + 160 + x] = 0x000000 - else: - ((unsigned *)0x15000)[(120 + y) * 320 + 160 + x] = 0xffffff + draw_ball () which = 2 break case Key::VOLUME_UP: // Set square. - for int y = -r; y < r; ++y: - for int x = -r; x < r; ++x: - ((unsigned *)0x15000)[(120 + y) * 320 + 160 + x] = 0xffffff + draw_square () which = 1 break if which != 0: diff --git a/memory.ccp b/memory.ccp index f16462a..989877f 100644 --- a/memory.ccp +++ b/memory.ccp @@ -1,4 +1,21 @@ #pypp 0 +// Iris: micro-kernel for a capability-based operating system. +// memory.ccp: Page allocation system. +// Copyright 2009 Bas Wijnen +// +// 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 . + #include "kernel.hh" //#define DEBUG_ALLOC diff --git a/source/ball.ccp b/source/ball.ccp index 7934214..742c807 100644 --- a/source/ball.ccp +++ b/source/ball.ccp @@ -1,4 +1,21 @@ #pypp 0 +// Iris: micro-kernel for a capability-based operating system. +// source/ball.ccp: Bouncing ball demo. +// Copyright 2009 Bas Wijnen +// +// 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 . + #include #include @@ -19,7 +36,7 @@ void ball (int x, int y, bool print): Kernel::Num start (): Kernel::my_parent.init_done () - colour = 0xffffff + colour = 0x3f30ff framebuffer = (unsigned *)0x15000 Display display = Kernel::my_parent.get_device (0x10000) int x = r, y = r, dx = 3, dy = 0 diff --git a/source/bsquare.ccp b/source/bsquare.ccp index dfd0ec7..b374bc1 100644 --- a/source/bsquare.ccp +++ b/source/bsquare.ccp @@ -1,4 +1,21 @@ #pypp 0 +// Iris: micro-kernel for a capability-based operating system. +// source/bsquare.ccp: Floating square demo. +// Copyright 2009 Bas Wijnen +// +// 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 . + #include #include @@ -17,7 +34,7 @@ void square (int x, int y, bool print): Kernel::Num start (): Kernel::my_parent.init_done () - colour = 0xffffff + colour = 0xffff00 framebuffer = (unsigned *)0x15000 Display display = Kernel::my_parent.get_device (0x10001) int x = r, y = r, dx = 3, dy = 3 diff --git a/source/display-emu.ccp b/source/display-emu.ccp index 97ed261..3236d26 100644 --- a/source/display-emu.ccp +++ b/source/display-emu.ccp @@ -1,4 +1,21 @@ #pypp 0 +// Iris: micro-kernel for a capability-based operating system. +// source/display-emu.ccp: Display interface emulation layer. +// Copyright 2009 Bas Wijnen +// +// 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 . + #include #include