3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
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)
62 if ((key
>= '0' && key
<= '9') || key
== '\b') {
91 void draw_button (unsigned char x
, unsigned char y
, unsigned active
, char c
)
150 for (r
= 0; r
< 25; r
++)
156 for (r
= 1; r
< 20; r
++) {
161 for (r
= 1; r
< 20; r
++) {
171 for (r
= 0; r
< 25; r
++)
184 for (r
= 0; r
< 21; r
++)
200 for (r
= 0; r
< 21; r
++)
207 void display_write (char *str
)
212 /* for (r = 0; r < 21; r ++)
215 //unsigned l = strlen (str);
222 unsigned key_handler ()
224 int scancode
= getkey ();
237 if (curr_button_y
> 0)
242 if (curr_button_y
< 3)
246 if (curr_button_x
> 0)
250 if (curr_button_x
< 3)
255 if (curr_button_x
== 0 && curr_button_y
== 1) {
262 if (curr_button_x
== 1 && curr_button_y
== 1) {
269 if (curr_button_x
== 2 && curr_button_y
== 1) {
276 if (curr_button_x
== 0 && curr_button_y
== 2) {
283 if (curr_button_x
== 1 && curr_button_y
== 2) {
290 if (curr_button_x
== 2 && curr_button_y
== 2) {
297 if (curr_button_x
== 0 && curr_button_y
== 3) {
304 if (curr_button_x
== 1 && curr_button_y
== 3) {
311 if (curr_button_x
== 2 && curr_button_y
== 3) {
318 if (curr_button_x
== 3 && curr_button_y
== 2) {
326 if (curr_button_x
== 3 && curr_button_y
== 0) {
330 number
+= atoi (buf
);
332 //memset (buf, 0, 15);
333 itoa (number
, buf
, 10);
335 //display_write (buf);
336 //buf_i = strlen (buf);
341 if (curr_button_x
== 3 && curr_button_y
== 3) {
345 //memset (buf, 0, 15);
346 itoa (number
, buf
, 10);
350 //buf_i = strlen (buf);
358 if (key
>= '0' && key
<= '9') {
364 //for (x = 0; x < buf_i; x ++)
370 draw_button (2, 7, 0, '/');
371 draw_button (8, 7, 0, '*');
372 draw_button (14, 7, 0, '-');
373 draw_button (20, 7, 0, '+');
376 draw_button (2, 10, 0, '7');
377 draw_button (8, 10, 0, '8');
378 draw_button (14, 10, 0, '9');
379 draw_button (20, 10, 0, 'C');
382 draw_button (2, 13, 0, '4');
383 draw_button (8, 13, 0, '5');
384 draw_button (14, 13, 0, '6');
385 draw_button (20, 13, 0, '0');
388 draw_button (2, 16, 0, '1');
389 draw_button (8, 16, 0, '2');
390 draw_button (14, 16, 0, '3');
391 draw_button (20, 16, 0, '=');
394 if (curr_button_x
== 0 && curr_button_y
== 0)
395 draw_button (2, 7, 1, '/');
397 draw_button (2, 7, 0, '/');
399 if (curr_button_x
== 1 && curr_button_y
== 0)
400 draw_button (8, 7, 1, '*');
402 draw_button (8, 7, 0, '*');
404 if (curr_button_x
== 2 && curr_button_y
== 0)
405 draw_button (14, 7, 1, '-');
407 draw_button (14, 7, 0, '-');
409 if (curr_button_x
== 3 && curr_button_y
== 0)
410 draw_button (20, 7, 1, '+');
412 draw_button (20, 7, 0, '+');
414 if (curr_button_x
== 0 && curr_button_y
== 1)
415 draw_button (2, 10, 1, '7');
417 draw_button (2, 10, 0, '7');
419 if (curr_button_x
== 1 && curr_button_y
== 1)
420 draw_button (8, 10, 1, '8');
422 draw_button (8, 10, 0, '8');
424 if (curr_button_x
== 2 && curr_button_y
== 1)
425 draw_button (14, 10, 1, '9');
427 draw_button (14, 10, 0, '9');
429 if (curr_button_x
== 3 && curr_button_y
== 1)
430 draw_button (20, 10, 1, 'C');
432 draw_button (20, 10, 0, 'C');
434 if (curr_button_x
== 0 && curr_button_y
== 2)
435 draw_button (2, 13, 1, '4');
437 draw_button (2, 13, 0, '4');
439 if (curr_button_x
== 1 && curr_button_y
== 2)
440 draw_button (8, 13, 1, '5');
442 draw_button (8, 13, 0, '5');
444 if (curr_button_x
== 2 && curr_button_y
== 2)
445 draw_button (14, 13, 1, '6');
447 draw_button (14, 13, 0, '6');
449 if (curr_button_x
== 3 && curr_button_y
== 2)
450 draw_button (20, 13, 1, '0');
452 draw_button (20, 13, 0, '0');
454 if (curr_button_x
== 0 && curr_button_y
== 3)
455 draw_button (2, 16, 1, '1');
457 draw_button (2, 16, 0, '1');
459 if (curr_button_x
== 1 && curr_button_y
== 3)
460 draw_button (8, 16, 1, '2');
462 draw_button (8, 16, 0, '2');
464 if (curr_button_x
== 2 && curr_button_y
== 3)
465 draw_button (14, 16, 1, '3');
467 draw_button (14, 16, 0, '3');
469 if (curr_button_x
== 3 && curr_button_y
== 3)
470 draw_button (20, 16, 1, '=');
472 draw_button (20, 16, 0, '=');
485 //display_write ("Ahoj svete !!");
492 char *buf
= (char *) malloc (sizeof (char) * 16);
516 char *buf
= (char *) malloc (sizeof (char) * 16);
517 //int *num = (char *) malloc (sizeof (int) * 5);
530 puts ("\nZadej prvni cislo: ");
532 puts ("\nZadej druhe cislo: ");
535 puts ("\nZadej operaci (+,-,*,/): ");
541 else if (oper
== '-')
543 else if (oper
== '*')
545 else if (oper
== '/')
556 //puts ("\nVysledek je: ");
561 int main (int argc
, char **argv
) // like main in a normal C program
566 if (!strcmp (arg, "-g"))