logohack exit on escape
[bootcensus] / src / kmain.c
1 /*
2 pcboot - bootable PC demo/game kernel
3 Copyright (C) 2018  John Tsiombikas <nuclear@member.fsf.org>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY, without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #include <stdio.h>
19 #include <string.h>
20 #include <ctype.h>
21 #include "segm.h"
22 #include "intr.h"
23 #include "keyb.h"
24 #include "timer.h"
25 #include "contty.h"
26 #include "video.h"
27
28
29 void logohack(void);
30
31 void pcboot_main(void)
32 {
33         init_segm();
34         init_intr();
35         kb_init();
36         con_init();
37
38         /* initialize the timer */
39         init_timer();
40
41         enable_intr();
42
43         printf("PCBoot kernel initialized\n");
44
45         for(;;) {
46                 int c;
47
48                 halt_cpu();
49                 while((c = kb_getkey()) >= 0) {
50                         if(c >= KB_F1 && c <= KB_F12) {
51                                 set_vga_mode(0x13);
52                                 logohack();
53                                 set_vga_mode(3);
54                         }
55                         if(isprint(c)) {
56                                 printf("key: %d '%c'       \n", c, (char)c);
57                         } else {
58                                 printf("key: %d            \n", c);
59                         }
60                 }
61                 if((nticks % 250) == 0) {
62                         printf("ticks: %ld\r", nticks);
63                 }
64         }
65 }