2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 #include <ao_profile.h>
27 #include <ao_console.h>
28 #include <ao_sdcard.h>
31 struct ao_task ball_task;
38 static int ball_dx, ball_dy;
51 ao_sleep(&ball_enable);
53 ao_line(&ao_vga_bitmap,
54 -100, -100, ball_x*2, ball_y*2,
56 ao_text(&ao_vga_bitmap,
60 ao_rect(&ao_vga_bitmap,
66 ao_delay(AO_MS_TO_TICKS(10));
67 ao_rect(&ao_vga_bitmap,
73 ao_text(&ao_vga_bitmap,
77 ao_line(&ao_vga_bitmap,
78 -100, -100, ball_x*2, ball_y*2,
84 if (ball_x + BALL_WIDTH > AO_VGA_WIDTH) {
85 ball_x = AO_VGA_WIDTH - BALL_WIDTH;
92 if (ball_y + BALL_HEIGHT > AO_VGA_HEIGHT) {
93 ball_y = AO_VGA_HEIGHT - BALL_HEIGHT;
107 ao_rect(&ao_vga_bitmap,
108 0, 0, AO_VGA_WIDTH, AO_VGA_HEIGHT,
111 ao_rect(&ao_vga_bitmap,
115 ao_rect(&ao_vga_bitmap,
116 AO_VGA_WIDTH - 20, 10, 10, 10,
119 ao_rect(&ao_vga_bitmap,
120 10, AO_VGA_HEIGHT - 20, 10, 10,
123 ao_rect(&ao_vga_bitmap,
124 AO_VGA_WIDTH - 20, AO_VGA_HEIGHT - 20, 10, 10,
127 ao_text(&ao_vga_bitmap,
132 ao_text(&ao_vga_bitmap,
137 ao_text(&ao_vga_bitmap,
138 1, AO_VGA_HEIGHT - ao_font.descent,
144 ao_video_toggle(void)
149 ao_vga_enable(ao_cmd_lex_i);
156 ball_enable = ao_cmd_lex_i;
157 ao_wakeup(&ball_enable);
161 ao_ps2_read_keys(void)
166 c = ao_ps2_getchar();
167 printf("%02x %c\n", c, ' ' <= c && c < 0x7f ? c : '.');
175 ao_console_send(void)
179 while ((c = getchar()) != '~') {
180 ao_console_putchar(c);
185 __code struct ao_cmds ao_demo_cmds[] = {
186 { ao_video_toggle, "V\0Toggle video" },
187 { ao_ball_toggle, "B\0Toggle ball" },
188 { ao_ps2_read_keys, "K\0Read keys from keyboard" },
189 { ao_console_send, "C\0Send data to console, end with ~" },
223 ao_add_task(&ball_task, ao_ball, "ball");
224 ao_cmd_register(&ao_demo_cmds[0]);
226 ao_start_scheduler();