blob: 4a8481bec39f8a5d05735b063300ddca51689ced [file] [log] [blame]
PulkoMandy612e2cf2021-09-20 23:00:40 +02001/*
2 * Copyright 2017, Adrien Destugues, pulkomandy@pulkomandy.tk
3 * Distributed under terms of the MIT license.
4 */
5
6
7#include "ctk-arch.h"
8#include "libconio.h"
9
10/* Keyboard management */
11ctk_arch_key_t
12ctk_arch_getkey(void)
13{
14 return 0;
15}
16
17unsigned char kbhit(void)
18{
19 return 0;
20}
21
22#if 0
23/* Mouse management */
24void ctk_mouse_init(void)
25{
26 mx = 50;
27 my = 20;
28}
29
30unsigned char ctk_mouse_xtoc(unsigned short x)
31{
32 return x;
33}
34
35unsigned char ctk_mouse_ytoc(unsigned short y)
36{
37 return y;
38}
39
40void ctk_mouse_hide(void)
41{
42 vram_attr[ctk_mouse_ytoc(my)][ctk_mouse_xtoc(mx)] &= ~32;
43}
44
45void ctk_mouse_show(void)
46{
47 vram_attr[ctk_mouse_ytoc(my)][ctk_mouse_xtoc(mx)] |= 32;
48}
49
50unsigned short ctk_mouse_x(void)
51{
52 if (mouse_x != 0)
53 {
54 ctk_mouse_hide();
55 mx += mouse_x; mouse_x = 0;
56 if (mx < 0) mx = 0;
57 if (mx >= LIBCONIO_SCREEN_WIDTH) mx = LIBCONIO_SCREEN_WIDTH - 1;
58 }
59 return mx;
60}
61
62unsigned short ctk_mouse_y(void)
63{
64 if (mouse_y != 0) {
65 ctk_mouse_hide();
66 my += mouse_y; mouse_y = 0;
67 if (my < 0) my = 0;
68 if (my >= LIBCONIO_SCREEN_HEIGHT) my = LIBCONIO_SCREEN_HEIGHT - 1;
69 }
70 return my;
71}
72
73unsigned char ctk_mouse_button(void)
74{
75 return mouse_buttons;
76}
77#endif
78
79extern int vram[];
80extern int vram_attr[];
81#define VRAM_WIDTH 64
82
83/* Character display */
84void
85ctk_arch_draw_char(char c,
86 unsigned char x, unsigned char y,
87 unsigned char reversed,
88 unsigned char color)
89{
90 vram[y * VRAM_WIDTH + x] = c;
91 if (x & 1) {
92 vram_attr[(y * VRAM_WIDTH + x) / 2] &= 0xff;
93 vram_attr[(y * VRAM_WIDTH + x) / 2] |= color << 8;
94 } else {
95 vram_attr[(y * VRAM_WIDTH + x) / 2] &= 0xff00;
96 vram_attr[(y * VRAM_WIDTH + x) / 2] |= color;
97 }
98}