PulkoMandy | 612e2cf | 2021-09-20 23:00:40 +0200 | [diff] [blame^] | 1 | /* |
| 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 */ |
| 11 | ctk_arch_key_t |
| 12 | ctk_arch_getkey(void) |
| 13 | { |
| 14 | return 0; |
| 15 | } |
| 16 | |
| 17 | unsigned char kbhit(void) |
| 18 | { |
| 19 | return 0; |
| 20 | } |
| 21 | |
| 22 | #if 0 |
| 23 | /* Mouse management */ |
| 24 | void ctk_mouse_init(void) |
| 25 | { |
| 26 | mx = 50; |
| 27 | my = 20; |
| 28 | } |
| 29 | |
| 30 | unsigned char ctk_mouse_xtoc(unsigned short x) |
| 31 | { |
| 32 | return x; |
| 33 | } |
| 34 | |
| 35 | unsigned char ctk_mouse_ytoc(unsigned short y) |
| 36 | { |
| 37 | return y; |
| 38 | } |
| 39 | |
| 40 | void ctk_mouse_hide(void) |
| 41 | { |
| 42 | vram_attr[ctk_mouse_ytoc(my)][ctk_mouse_xtoc(mx)] &= ~32; |
| 43 | } |
| 44 | |
| 45 | void ctk_mouse_show(void) |
| 46 | { |
| 47 | vram_attr[ctk_mouse_ytoc(my)][ctk_mouse_xtoc(mx)] |= 32; |
| 48 | } |
| 49 | |
| 50 | unsigned 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 | |
| 62 | unsigned 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 | |
| 73 | unsigned char ctk_mouse_button(void) |
| 74 | { |
| 75 | return mouse_buttons; |
| 76 | } |
| 77 | #endif |
| 78 | |
| 79 | extern int vram[]; |
| 80 | extern int vram_attr[]; |
| 81 | #define VRAM_WIDTH 64 |
| 82 | |
| 83 | /* Character display */ |
| 84 | void |
| 85 | ctk_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 | } |