3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
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.
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.
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/>.
37 unsigned char curr_button_x
= 0;
38 unsigned char curr_button_y
= 0;
42 unsigned key_pressed (int keycode
)
44 int scancode
= getkey ();
46 if (scancode
== keycode
)
49 if (scancode
== keycode
+128)
63 if ((key
>= '0' && key
<= '9') || key
== '\b') {
94 void draw_button (unsigned char x
, unsigned char y
, unsigned active
, char c
)
153 for (r
= 0; r
< 25; r
++)
159 for (r
= 1; r
< 20; r
++) {
164 for (r
= 1; r
< 20; r
++) {
174 for (r
= 0; r
< 25; r
++)
187 for (r
= 0; r
< 21; r
++)
203 for (r
= 0; r
< 21; r
++)
210 void display_write (char *str
)
214 /* for (r = 0; r < 21; r ++)
217 //unsigned l = strlen (str);
224 unsigned key_handler ()
226 int scancode
= getkey ();
239 if (curr_button_y
> 0)
244 if (curr_button_y
< 3)
248 if (curr_button_x
> 0)
252 if (curr_button_x
< 3)
257 if (curr_button_x
== 0 && curr_button_y
== 1) {
264 if (curr_button_x
== 1 && curr_button_y
== 1) {
271 if (curr_button_x
== 2 && curr_button_y
== 1) {
278 if (curr_button_x
== 0 && curr_button_y
== 2) {
285 if (curr_button_x
== 1 && curr_button_y
== 2) {
292 if (curr_button_x
== 2 && curr_button_y
== 2) {
299 if (curr_button_x
== 0 && curr_button_y
== 3) {
306 if (curr_button_x
== 1 && curr_button_y
== 3) {
313 if (curr_button_x
== 2 && curr_button_y
== 3) {
320 if (curr_button_x
== 3 && curr_button_y
== 2) {
328 if (curr_button_x
== 3 && curr_button_y
== 0) {
332 number
+= atoi (buf
);
334 //memset (buf, 0, 15);
335 itoa (number
, buf
, 10);
337 //display_write (buf);
338 //buf_i = strlen (buf);
343 if (curr_button_x
== 3 && curr_button_y
== 3) {
347 //memset (buf, 0, 15);
348 itoa (number
, buf
, 10);
352 //buf_i = strlen (buf);
360 if (key
>= '0' && key
<= '9') {
366 //for (x = 0; x < buf_i; x ++)
372 draw_button (2, 7, 0, '/');
373 draw_button (8, 7, 0, '*');
374 draw_button (14, 7, 0, '-');
375 draw_button (20, 7, 0, '+');
378 draw_button (2, 10, 0, '7');
379 draw_button (8, 10, 0, '8');
380 draw_button (14, 10, 0, '9');
381 draw_button (20, 10, 0, 'C');
384 draw_button (2, 13, 0, '4');
385 draw_button (8, 13, 0, '5');
386 draw_button (14, 13, 0, '6');
387 draw_button (20, 13, 0, '0');
390 draw_button (2, 16, 0, '1');
391 draw_button (8, 16, 0, '2');
392 draw_button (14, 16, 0, '3');
393 draw_button (20, 16, 0, '=');
396 if (curr_button_x
== 0 && curr_button_y
== 0)
397 draw_button (2, 7, 1, '/');
399 draw_button (2, 7, 0, '/');
401 if (curr_button_x
== 1 && curr_button_y
== 0)
402 draw_button (8, 7, 1, '*');
404 draw_button (8, 7, 0, '*');
406 if (curr_button_x
== 2 && curr_button_y
== 0)
407 draw_button (14, 7, 1, '-');
409 draw_button (14, 7, 0, '-');
411 if (curr_button_x
== 3 && curr_button_y
== 0)
412 draw_button (20, 7, 1, '+');
414 draw_button (20, 7, 0, '+');
416 if (curr_button_x
== 0 && curr_button_y
== 1)
417 draw_button (2, 10, 1, '7');
419 draw_button (2, 10, 0, '7');
421 if (curr_button_x
== 1 && curr_button_y
== 1)
422 draw_button (8, 10, 1, '8');
424 draw_button (8, 10, 0, '8');
426 if (curr_button_x
== 2 && curr_button_y
== 1)
427 draw_button (14, 10, 1, '9');
429 draw_button (14, 10, 0, '9');
431 if (curr_button_x
== 3 && curr_button_y
== 1)
432 draw_button (20, 10, 1, 'C');
434 draw_button (20, 10, 0, 'C');
436 if (curr_button_x
== 0 && curr_button_y
== 2)
437 draw_button (2, 13, 1, '4');
439 draw_button (2, 13, 0, '4');
441 if (curr_button_x
== 1 && curr_button_y
== 2)
442 draw_button (8, 13, 1, '5');
444 draw_button (8, 13, 0, '5');
446 if (curr_button_x
== 2 && curr_button_y
== 2)
447 draw_button (14, 13, 1, '6');
449 draw_button (14, 13, 0, '6');
451 if (curr_button_x
== 3 && curr_button_y
== 2)
452 draw_button (20, 13, 1, '0');
454 draw_button (20, 13, 0, '0');
456 if (curr_button_x
== 0 && curr_button_y
== 3)
457 draw_button (2, 16, 1, '1');
459 draw_button (2, 16, 0, '1');
461 if (curr_button_x
== 1 && curr_button_y
== 3)
462 draw_button (8, 16, 1, '2');
464 draw_button (8, 16, 0, '2');
466 if (curr_button_x
== 2 && curr_button_y
== 3)
467 draw_button (14, 16, 1, '3');
469 draw_button (14, 16, 0, '3');
471 if (curr_button_x
== 3 && curr_button_y
== 3)
472 draw_button (20, 16, 1, '=');
474 draw_button (20, 16, 0, '=');
487 //display_write ("Ahoj svete !!");
494 buf
= (char *) malloc (sizeof (char) * 16);
522 buf
= (char *) malloc (sizeof (char) * 16);
526 printf ("\nType first number: ");
529 printf ("\nSecond number: ");
532 printf ("\nChoose operation (+,-,*,/): ");
538 else if (oper
== '-')
540 else if (oper
== '*')
542 else if (oper
== '/')
545 printf ("\nResult: %d\n", res
);
550 int main (int argc
, char **argv
) // like main in a normal C program
555 if (!strcmp (argv
[1], "-g"))